Skip to content

Printf Project: Making our own printf project with C language

Notifications You must be signed in to change notification settings

valen2510/printf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Printf project

Description

printf is a weel known function used in C programming to do formated printing. Usually it only takes the standard library to call it into a c program, and using it for simple strings or formatted specifiers that allow us to print diferent types of data. This time we are presenting a printf project made from scratch in most of its features in order to understand the complexity of a powerful tool. You can see man 3 of printf to understand how _printf works.

Compilation

$ gcc -Wall -Werror -Wextra -pedantic *.c

Prototype

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

Return

If everything is succesful the function returns the number of characteres printed.

Formats

Specifiers Description
%c Print single character
%s Print string of characteres
%d Print decimal numbers
%i Print integers

Project files

File Description
holberton.h Header file
Include all function prototypes
Include structure of specifiers
printf.c Project function: _printf
Start the variadic list.
Iterates string format of entry and check for a moldule symbol (%) . If the symbol is found then check if the next char match with one of the valid specifiers in the structure using the auxiliar function to comapare ( comp), in that case the respective function of these format is called.
For the characters that doesn't match any of the formats the function ignores the module symbole and print it as a string.
In case that the module symbole is not found, print the each character normally.
printf_functions.c Auxiliar functions
_putchar: using write function, prints a character
printc: print character using list variable.
print_string: pint strings, if string is null it pirnts (null)
print_n: print numbers base 10.

Contributors

Mauricio Garcia - @camagar
Valentina Jaramillo - @valen2510

About

Printf Project: Making our own printf project with C language

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages