diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..0e11aca --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,33 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "windows-msvc-x64" + }, + { + "name": "includePath", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "windows-msvc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..691a8f6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "C_Cpp.errorSquiggles": "Disabled" +} \ No newline at end of file diff --git a/_printf.c b/_printf.c new file mode 100644 index 0000000..774ad4b --- /dev/null +++ b/_printf.c @@ -0,0 +1,43 @@ +#include "main.h" + +/** + * _printf - produces output according to a format + * @format: format string containing the characters and the specifiers + * Description: this function will call the get_print() function that will + * determine which printing function to call depending on the conversion + * specifiers contained into fmt + * Return: length of the formatted output string + */ +int _printf(const char *format, ...) +{ + register short len = 0; + int (*printFunc)(va_list, mods *); + mods prefixes = PF_INIT; + const char *p = format; + va_list arguments; + + va_start(arguments, format); + assert(invalidInputs(p)); + for (; *p; p++) + { + if (*p == '%') + { + p++; + if (*p == '%') + { + len += _putchar('%'); + continue; + } + while (get_flags(*p, &prefixes)) + p++; + printFunc = get_print(*p); + len += (printFunc) + ? printFunc(arguments, &prefixes) + : _printf("%%%c", *p); + } else + len += _putchar(*p); + } + _putchar(FLUSH); + va_end(arguments); + return (len); +} diff --git a/main.h b/main.h new file mode 100644 index 0000000..ed4bbc0 --- /dev/null +++ b/main.h @@ -0,0 +1,5 @@ +#ifndef MAIN_H +#define MAIN_H +#include + +#endif