This is a simple implementation of the printf function in C. It is a project for ALX curriculum.
The function is called _printf
and it takes a format string and an arbitrary number of arguments. The format string is a string that contains zero or more directives. Each directive is introduced by a percent sign (%
) and ends with a conversion specifier. The conversion specifier is a character that specifies the type of conversion to be applied. The _printf
function writes output to stdout, the standard output stream.
The _printf
function returns the number of characters printed (excluding the null byte used to end output to strings).
The following conversion specifiers are supported:
Specifier | Output |
---|---|
c |
Character |
s |
String of characters |
% |
Percent sign |
d |
Signed decimal integer |
i |
Signed decimal integer |
b |
Unsigned binary |
u |
Unsigned decimal integer |
o |
Unsigned octal |
x |
Unsigned hexadecimal integer (lowercase) |
X |
Unsigned hexadecimal integer (uppercase) |
S |
String of non-printable characters (preceded by \x ) |
p |
Pointer address |
r |
Reversed string |
R |
Rot13 string |
The _printf
function is compiled with the following command:
gcc -Wall -Werror -Wextra -pedantic *.c
a.out
_printf("Let's try to printf a simple sentence.\n");
_printf("Character:[%c]\n", 'H');
_printf("String:[%s]\n", "I am a string !");
Let's try to printf a simple sentence.
Character:[H]
String:[I am a string !]
-
Asim S. Abdelgadir - Sudagoarth Co.Ltd - Twitter - Linkedin - Github - Facebook - Medium
-
Saif S. Sabit - Twitter - Linkedin - Github - Facebook - Medium
This project is licensed under the MIT License - see the LICENSE.md file for details
- ALX School
- Stack Overflow
- C Programming Language
- The Linux Programming Interface
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.