Skip to content

LuisaPinillos/printf

Repository files navigation

The C - Printf Project

¡we have created our own printf function!
we invite you to continue reading our project

objetive

Github

  • 🔭 The goal of this project in developing our own function (printf) is to fully understand how code works and to significantly understand the value of being a programmer.

_PRINTF

  • 💬 To describe our function we will start by saying that it is made inspired by the original function (printf), but of which I will explain its usefulness and give you some examples of how to test our function in your code.

  • 💻 ¿What is it and what is it for? ..

  • The _printf function is a functionality that allows us to print messages on the user's screen, which can be used to display characters, strings, numbers, data, etc. Of which for this we will need some specifiers that I will show you next.

  • 💻 Syntax ..

  • In the control chain the specifier of the data output format must be indicated, it can also have ordinary text and the escape sequence. this string of characters must be enclosed in double quotes. Format of the format string the characters are copied verbatim into the function's output, but the format specifiers, which start with a % character, indicate the location and method of translating data (such as a number) into characters.

  • 📌 specifiers ..

  • 🛠 [%c] - If there is no l modifier present, the int argument is converted to an unsigned character and the resulting character is written.

  • 🛠 [%s] - If no l modifier is present, the const char * argument is expected to be a pointer to an array of character type (pointer to a string). Characters from the array are written up to a terminating null byte (' ').

  • 🛠 [%%] - Print the % character.

  • 🛠 [%d]-[%i] - The int argument is converted to signed decimal notation. The precision, if any, gives the minimum number of digits that must appear; if the converted value requires fewer digits, it is padded on the left with zeros.

  • 🤖 How to use them ..

  • ✅ Add the library "holberton.h"

  • ✅ Create a file "main.c"

  • ✅ Identify the specifier and functionality for which you will use our function.

  • ✅ Code it as in the following example.

  • ✅ To show the output compile it with the following flags

  • gcc -Wall -Wextra -Werror -pedantic -std=gnu89 -Wno-format *.c

  • ✅ Run it with

  • ./a.out

Example

  • INPUT ..
{ #include "holberton.h"
int main(void)
char character = 'H';
char *name = "Holberton";
int year = 2021;
char percentage = '%';

_printf("initial letter: %c\n", character);
_printf("The school is: %s\n", name);
_printf("year: %i\n", year);
_printf("sign percentage is: %%\n", percentage);
return (0);

}

  • OUTPUT ..
initial letter: H
The school is: Holberton
year: 2021
sign percentage is: %

contributors

Luisa Pinillos
Laura Caicedo

The end
¡Thank you!

About

We create our Printf function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages