Skip to content

sunko-seoul/printf

Repository files navigation

School 42 printf()

This repository contains all files for the printf project from School 42 Seoul cursus. The project consist in duplicate the printf() function, part of the stdio.h library.

About

This project consists in duplicate the behavior of the C function printf(). It is not necessary to implement the buffer management of the original function. It must handle the following parameters:

  • char type variables.
  • string type variables.
  • int type variables.
  • unsigned int type variables.
  • hexadecimal int type variables (uppercase and lowercase).
  • pointer type variables.

Index

Structure

The main obstacles during the execution of the project have been: handling a variable number of parameters and the function ft_printf() returning an int.

va_list

To deal with the variable number of parameters entered, the macros va_list, va_start, va_arg and va_end have been used. The ft_printf() function calls the ft_fotmat() function when it finds the % sign among the entered parameters, then it checks the next character in the string to call one of the functions that print the different variable types. To use this macro, the libraryt <stdarg.h> is included in the ft_printf.h.

Returning an integer

To handle the integer returned by ft_printf(), a pointer is given in the format printing functions. In this way, the function handles the number of characters printed before continuing with the string sent by parameter. Example:

Requirements

The functions are written in C language and need the gcc compiler, with <stdlib.h>, <stdarg.h> and <unistd.h> standard libraries to run.

Instructions

1. Compiling the archives

To compile the proiect, go to its path and run:

For mandatory functions:

$ make

2. Cleaning all binary (.o) and executable files (.a)

To delete all files generated with make, go to the path and run:

$ make fclean

3. Using it in your code

To use this project in your code, simply include this header:

#include "ft_printf.h"

Testing

This function have been tested with Francinette.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published