A formatted output conversion C program. It is a pseudo-recreation of the C standard library function printf
int _printf(const char *format, ...);
All files will be complied on Ubuntu 20.04LTS using gcc, using the options gcc -Wall -Werror -Wextra -pedantic -Wno-format -std=gnu89 *.c
After complilation, _printf()
is ready for use.
include "printf.h"
int main(void)
{
_printf("This is an implementation of %s\n", "printf");
}
Complilation:
gcc -Wall -Werror -Wextra -pedantic -Wno-format -std=gnu89 *.c -o tester
Output:
$ ./tester
This is an implementation of printf
$
The _printf()
function produces output in accordance to a specified format. This function prints its output to the stdout and returns the length of the output when successful.
- %c: Character specifier
- %d: Decimal specifier
- %i: Integer specifier
- %s: String specifier (character pointer)
- %%: Print the percentage sign
- %o: Octal specifier
- %x: Hexadecimal specifier
- %X: Hexadecimal specifier (Uppercase)
- %p: Address specifier
- %b: Binary specifier
- %R: rot13'ed specifier
- %r: reversed specifier
- %S: String specifier. (Non printable characters (0 < ASCII value < 32 or >= 127) are printed this way: \x, followed by the ASCII code value in hexadecimal (upper case - always 2 characters))
This project was written as part of the curriculum for Holberton/ALX-SE program