_printf is a custom implementation of the C programming function printf. This project is an application of the C programming knowledge that ALX School cohort 8 students have learned since starting the program on May 1, 2021.
Prototype: int _printf(const char *, ...);
String
- Input:
_printf("%s\n", 'This is a string.'); - Output:
This is a string.
Character
- Input:
_printf("The first letter in the alphabet is %c\n", 'A'); - Output:
The first letter in the alphabet is A
Integer
- Input:
_printf("There are %i dozens in a gross\n", 12); - Output:
There are 12 dozens in a gross
Decimal:
- Input:
_printf("%d\n", 1000); - Output:
1000
- All files will be compiled on
Ubuntu 20.04 LTS - Programs and functions will be ccompiled using the GNU compiler collection v.
gcc, using the options-Wall -Werror -Wextra -pedantic -std=gnu89 - Code must follow the Betty style
- Global variables are not allowed
- Authorized functions and macros:
write(man 2 write)malloc(man 3 malloc)free(man 3 free)va_start(man 3 va_start)va_end(man 3 va_end)va_copy(man 3 va_copy)va_arg(man 3 va_arg)
- Write function that produces output with conversion specifiers
c,s, and%. - Handle conversion specifiers
d,i. - Create a man page for your function.
- Handle conversion specifier
b. - Handle conversion specifiers
u,o,x,X. - Use a local buffer of 1024 chars in order to call write as little as possible.
- Handle conversion specifier
S. - Handle conversion specifier
p. - Handle flag characters
+, space, and#for non-custom conversion specifiers. - Handle length modifiers
landhfor non-custom conversion specifiers. - Handle the field width for non-custom conversion specifiers.
- Handle the precision for non-custom conversion specifiers.
- Handle the
0flag character for non-custom conversion specifiers. - Handle the custom conversion specifier
rthat prints the reversed string. - Handle the custom conversion specifier
Rthat prints the rot13'ed string. - All above options should work well together.
- _printf.c: - contains the fucntion
_printf, which uses the prototypeint _printf(const char *format, ...);. The format string is composed of zero or more directives. Seeman 3 printffor more detail. _printf will return the number of characters printed (excluding the null byte used to end output to strings) and will write output to stdout, the standard output stream. - _putchar.c: - contains the function
_putchar, which writes a character to stdout. - main.h: - contains all function prototypes used for
_printf. - man_3_printf: - manual page for the custom
_printffunction. - print_chars.c: - contains the functions
print_c,print_s,print_S, andprint_rwhich handle the conversion specifiersc,s,S, andr, respectively, as well ashex_print, which prints a char's ascii value in uppercase hex - print_numbers.c: - contains the functions
print_iandprint_d, which handle the conversion specifiersiandd, respectively - print_hex.c: - contains the functions
print_hex, which prints an unsigned int in hexidecimal form,print_x,print_X, andprint_p, which handle the conversion specifiersx,X, andp, respectively - print_unsigned_int.c: - contains the functions
print_u,print_o, andprint_b, which handle the conversion specifiersu,o, andb, respectively - print_rot13.c - contains the function
print_R, which handles the conversion specifierR
Seid Muhammed | GitHub | Twitter
Selehadin Seid | GitHub