It is a simple prototype of the original printf function used in the C.
This function is designed to output according to a format as detailed below. This function writes its output to the standard output, the standard output stream.
-
Allowed editors:
vi
,vim
,emacs
-
Programs and functions will be compiled with
gcc 4.8.4
using the flags-Wall
-Werror
-Wextra
and -pedantic
-
All files should end with a new line
-
Code should use the
Betty
style. it will be checked using [betty-style.pl](https://github.com/holbertonschool/Betty/blob/master/betty-style\ .pl) and betty-doc.pl -
No more than 5 functions per file
-
All your header files should be include guarded
-
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)
Git clone the repository:
git clone https://github.com/cbarros7/simple_printf.git
All the files are to be compiled on an Ubuntu 14.04 LTS machine with:
gcc -Wall -Werror -Wextra -pedantic *.c -o printf
Once compiled, to start the program, run:
./printf
To use _printf you have to use the following key characters preceeded by % symbol.
Function Name | Description |
---|---|
%c | To be used to print characters. |
%s | To be used to print strings. |
%i | To be used to print number integers. |
%d | To be used to print number integers. |
%x | To be used to print number in octal . |
%% | To be used to print a porcentage symbol. |
Function Name | Description |
---|---|
find_match | Find coincidences in the string. |
_printf | Copy of funtion boult.in printf. |
print_int | Print integer and length. |
print_char | Print character and length. |
print_str | Print character to character and length. |
print_porcent | Print simbol %%. |
_write_char | Writes the character c to stdout. |
Use cases |
---|
_printf("%c", 'S'); |
_printf("A char inside a sentence: %c. Did it work?\n", 'F'); |
_printf("Let'see if the cast is correctly done: %c. Did it work?\n", 48); |
_printf("%s", "This sentence is retrieved from va_args!\n"); |
_printf("Complete the sentence: You %s nothing, Jon Snow.\n", "know"); |
_printf("Complete the sentence: You %s nothing, Jon Snow.\n", (char *)0); |
_printf("%c%cth %s%s a%cg%s: Y%sou %s no%ching%s Snow.%c", 'W', 'i', "some ", "more", 'r', "s", "", "know", 't', ", Jon", '\n');] |
_printf("%%"); |
_printf("Should print a single percent sign: %%\n"); |
_printf("%s%c%c%c%s%%%s%c", "Loading ", '.', '.', '.', " 99", " Please wait", '\n'); |
_printf("css%ccs%scscscs\n", 'T', "Test"); |
_printf(NULL); |
_printf("%c", '\0'); |
_printf("%"); |
_printf("%!\n"); |
_printf("%K\n"); |
The function will always return an integer, corresponding to the symbol, without countingthe null string.
No known bugs.
Thanks to all the software engineers, colleagues from different cohorts of the Holberton School, for all the learning we have been able to acquire in this project, it has undoubtedly allowed us to expand our knowledge in the C programming language.
For more information about Holberton, visit this link.