Skip to content

rinagm/ft_printf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

My printf in C πŸ“ in 42 Madrid

My second Project in 42 is to replicate the printf function in C.

Variadic function

In this project is required to use the variadic functions.

Variadic functions are functions that may be called with different numbers of arguments.
When a variadic function is called, all parameters are stored on the stack by the compiler and initialized with macros:

  • The necessary information is stored in va_list
  • Initialise parameter access with va_start
  • Get a new parameter with each call to va_arg
  • Finish with va_end

Is required to use the library <stdarg.h>
When it finds the '%' character, it calls the conversion function and formats it according to the corresponding conversion specifier (the character after the `'%').

Project ft_prinft

This project consists of duplicating the behavior of the C function printf().

int ft_printf(const char *, ...);

The printf function returns the number of characters printed, or a negative value if an error occurs.

Supported conversions:

%c - Prints a single character
%s - Prints a string
%p - Prints a pointer address
%d or %i - Prints a signed integer
%u - Prints an unsigned integer
%x or %X - Prints an unsigned integer in hexadecimal format ("0123456789abcdef")

Used functions

ft_putchar ft_putstr ft_ptr ft_putnbr ft_unsigned ft_hex

About

My own printf πŸ“

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors