Skip to content

This project is about recoding printf function from the stdio library.

Notifications You must be signed in to change notification settings

manettifabrizio/42cursus_ft_printf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🖨 ft_printf 🖨

CURSUS: 2019 - AUTHOR: fmanetti - GRADE: 107 - FINISHED: 25/04/2020

The goal of this project is recode printf(). You will mainly learn about using a variable number of arguments.

image

Introduction

You will discover a popular and versatile C function: printf(). This exercise is a great opportunity to improve your programming skills. It is of moderate difficulty. You will discover variadic functions in C. The key to a successful ft_printf is a well-structured and extensible code.

For more detailed information, look at the subject of this project.

Disclaimer

At 42 school when we program in C we are subject to a set of rules called the norm, so if the code is not 100% optimized this is the reason. This project was coded following norminette v2.

Implemented conversions

  • %c: Prints a single character.
  • %s: Prints a string (as defined by the common C convention).
  • %p: The void * pointer argument has to be printed in hexadecimal format.
  • %d: Prints a decimal (base 10) number.
  • %i: Prints an integer in base 10.
  • %u: Prints an unsigned decimal (base 10) number.
  • %x: Prints a number in hexadecimal (base 16) lowercase format.
  • %X: Prints a number in hexadecimal (base 16) uppercase format.
  • %%: Prints a percent sign.

Implemented flags

  • -: Left adjustment of the output in the indicated field.
  • 0: Indicating that zero-padding should be used rather than blank-padding.
  • .: Precision.

Bonus conversions

  • %f: Prints a float with signed value in the form [-]dddd.dddd, where dddd is one or more decimal digits.
  • %e: Prints a float with signed value in the form [-]d.dddde±dd[d], where d is one decimal digit.

Bonus flags

  • #: A `#' character specifying that the value should be printed in an ``alternate form''.
  • ' ': A space specifying that a blank should be left before a positive number for a signed format.
  • +: A `+' character specifying that there should always be a sign placed before the number when using signed formats.

Usage

Requirements

The function is written in C language and thus needs the gcc compiler and some standard C libraries to run.

Instructions

1. Compiling the library

To compile, go to the library path and run:

$ make

2. Using it in your code

To use the library functions in your code, simply include its header:

#include "ft_printf.h"

Testing

Sources

Microsoft Docs

About

This project is about recoding printf function from the stdio library.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published