own printf shell function
En este proyecto programamos desde cero una función igual a printf() en C. La función permite imprimir de acuerdo a los especificadores de formato de tal forma que puede imprimir caracteres, strings, números positivos y negativos, en hexadecimal, binario, octal y direcciones de memoria entre otros.
Demo: https://nulltagram.herokuapp.com/
stack
- C
- gcc new build
- Linux
- github repo
User Guide
_printf project
Description
In _printf project we code from zero our own custom printf function. Native printf function allows you to print with certain formats. We handle most basic format so you can print chars, strings, positive and negative numbers, hex, octa and binary numbers among other formats. You can see man 3 of printf to understand how printf works.
Usage
Compile
gcc -Wall -Werror -Wextra -pedantic *.c -o executable
Prototype
int _printf(const char *format, ...)
Return
If everything is successful, the function returns the num of chars printed.
Format conversion
Format | Description |
---|---|
c | Print char values |
s | Print strings |
d, i | Print numbers [positive and negative] |
b | Print nums converted to binary |
u | Print nums as unsigned int |
o | Print nums converted to octal |
x | Print nums converted to hexa [uppercase] |
X | Print nums converted to hexa [uppercase] |
%% | Print % character |
p | Print memory adress [pointers] |
r | Print string in reverse |
S | Print string and non-printable chars [\x + ASCII value in hexa] |
R | Print in rot13 |