Skip to content

A custom imitation of printf() C function as located in stdio.h library

Notifications You must be signed in to change notification settings

iamthatjude/printf

Repository files navigation

The printf() Project

The printf project was done by Jude Okpara, a C13 Software Engineering student at ALX. A function named "_printf" imitates the actual "printf" C command/function located in the stdio.h library. It contains some of the basic features and functions found in the manual 3 of "printf".

_printf() is a function that performs formatted output conversion and print data. Its prototype is the following:

int _printf(const char *format, ...)

Where format contains the string that is printed. As _printf() is variadic function, it can receives n arguments that replace by n tags written inside the string.

The format tags prototype is the following:

%[flags][length]specifier

If the program runs successfully, the return value is the amount of chars printed.

Specifier Output
c Character
d or i Signed decimal integer
s String of characters
b Signed binary
o Signed octal
u Unsigned integer
x Unsigned hexadecimal
X Unsigned hexadecimal (uppercase)
p Pointer address
r Reverse string of characters
R ROT13 translation of string
S String with special chars replaced by their ASCII value
% Character
Flags Description Specifiers
+ Prints a plus sign (+) when the argument is a positive number. In other case, prints a minus sign (-). i, d
(space) Prints a blank space if the argument is a positive number i, d
# Prints 0, 0x and 0X for o, x and X specifiers, respectively. It doesn't print anything if the argument is zero o, x, X
Length Description Specifiers
l Prints a long int or unsigned long int i, d, o, u, x and X
h Prints a short int or unsigned short int i, d, o, u, x and X

Examples


File Functions

Authors

Jude Okpara.


End

Releases

No releases published

Packages

No packages published

Languages