This project is to recreate the printf function in C with its most important features, it was made in the software development program of Holberton School.
The man page is a file wich explains in detail how the function works. If you want see a full explanation of this function you can run our man page this way:
$ man ./man_3_printf
Syntaxis
#include <stdio.h>
#include <stdarg.h>
int _printf(const char *format, ...);
Compilation
$ gcc -Wall -Werror -Wextra -pedantic -std=gnu89 -Wno-format *.c
Supported Conversion Specifiers
- %c : Prints a character.
- %s : Prints a string of characters.
- %i & %d : Prints a signed integer in base 10.
- %% : Prints a literal % character.
#include <stdio.h>
int _printf(const char *format, ...);
int main()
{
char ch = 'A';
char str[] = "Hello, World!";
int num = 42;
// Test of the %c specifier
_printf("Character: %c\n", ch);
// Test of the %s specifier
_printf("String: %s\n", str);
// Test of the %i specifier
_printf("Number: %i\n", num);
// Test of the %% specifier
_printf("Percent sign: %%\n");
// Test of multiple specifiers in the same string
_printf("Character: %c, String: %s, Number: %i\n", ch, str, num);
// Test with an empty string
_printf("Empty string: %s\n", "");
// Test with a null character (empty string)
char empty_str[] = {0};
_printf("Empty string: %s\n", empty_str);
return (0);
}
Outpout :
Character: A
String: Hello, World!
Number: 42
Percent sign: %
Character: A, String: Hello, World!, Number: 42
Empty string:
Empty string:
This program is distributed under the terms of the Holberton license.