Skip to content

"printf" stands for "print formatted" and is one of the main C output functions, it prints a string on the screen using a predefined “format string”, this project emulates some of its functionalities.

License

Notifications You must be signed in to change notification settings

schambig/holbertonschool-printf

Repository files navigation

License: MIT made-with-Markdown

_printf

_printf

Table of Contents

Description

"printf" stands for "print formatted" and is one of the main C output functions, it prints a string on the screen using a predefined “format string”, this project emulates some of its functionalities.

Prototype: int _printf(const char *, ...);

Format Specifiers

Format Specifier Function name Description
c is_char Print a single character
s is_string Print a string of characters
d is_integer Print a decimal (base 10) number
i is_integer Print an integer in base 10

Flowcharts

_printf

parser

Imgur

Installation

To use this custom _printf function you need <stdio.h>, <stdarg.h>, <string.h> and <stddef.h> libraries.

First, clone this repository to your local machine :

$ git clone https://github.com/schambig/holbertonschool-printf.git

Then, go to the repository folder:

$ cd holbertonschool-printf

Finally, you can compile it with your C source code:

$ gcc *.c [your_code] -o [outfile_name]

You can also make it portable, creating a static library, follow the these steps:

Once cloned (first step above) go to the repository folder, and get the object files:

$ gcc -c *.c 

Then create the static library:

$ ar -rc libprintf.a *.o

Once the static library is created, create and update the index of the just created library (this speed up the compilation process):

$ ranlib libprintf.a

Now you will have printf.a static library, and all you have to do is compile your code with this library:

$ gcc [your_code] -L. -lprintf -o [outfile_name]

Examples

Character

  • Input:
_printf("%c is fun!\n", 'C');
  • Output:
C is fun!

String

  • Input:
_printf("%s\n", "Read the fucking manual.");
  • Output:
Read the fucking manual.

Integer or Decimal

  • Input:
_printf("Today is July %i.\n", 12);
  • Output:
Today is July 12.

Percentage

  • Input:
_printf("We've finished the 100%% of the mandatory tasks.\n");
  • Output:
We've finished the 100% of the mandatory tasks.

Authors


Joel Melgarejo

Salomón Chambi

Back to top

About

"printf" stands for "print formatted" and is one of the main C output functions, it prints a string on the screen using a predefined “format string”, this project emulates some of its functionalities.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages