Skip to content

mistWil/holbertonschool-printf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

63eea844ae4e3022154e2878_Holberton-removebg-preview

CREATING A CUSTOM PRINTF FUNCTION

GENERAL PRESENTATION 📎

In this project, the goal is to recreate the printf function, available in the standard library in the C language. This function allows the display of characters on the user interface.

COMPILATION

The compilation command to compile the files that make up the printf function is as follows:


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


REQUIREMENTS

The imposed requirements for this project are as follows:

  1. Use of Vi
  2. Use of Ubuntu 20.04 LTS
  3. The code must follow the Betty style
  4. Prohibition of using global variables
  5. All files must end with a newline
  6. Not more than 5 functions per file
  7. All .c files must include the "main.h" header

Specifiers 📔

SPECIFIER DESCRIPTION
%s print null-terminated string
%c print single character
%% print '%' character
%d print decimal number
%i print integer number

USAGE EXAMPLE


INPUT:


int main(void)
{
    int len;
    int len2;
    unsigned int ui;
    void *addr;

    len = _printf("Let's try to printf a simple sentence.\n");
    len2 = printf("Let's try to printf a simple sentence.\n");
    ui = (unsigned int)INT_MAX + 1024;
    addr = (void *)0x7ffe637541f0;
    _printf("Length:[%d, %i]\n", len, len);
    printf("Length:[%d, %i]\n", len2, len2);
    _printf("Negative:[%d]\n", -762534);
    printf("Negative:[%d]\n", -762534);
    _printf("Unsigned:[%u]\n", ui);
    printf("Unsigned:[%u]\n", ui);
    _printf("Unsigned octal:[%o]\n", ui);
    printf("Unsigned octal:[%o]\n", ui);
    _printf("Unsigned hexadecimal:[%x, %X]\n", ui, ui);
    printf("Unsigned hexadecimal:[%x, %X]\n", ui, ui);
    _printf("Character:[%c]\n", 'H');
    printf("Character:[%c]\n", 'H');
    _printf("String:[%s]\n", "I am a string !");
    printf("String:[%s]\n", "I am a string !");
    _printf("Address:[%p]\n", addr);
    printf("Address:[%p]\n", addr);
    len = _printf("Percent:[%%]\n");
    len2 = printf("Percent:[%%]\n");
    _printf("Len:[%d]\n", len);
    printf("Len:[%d]\n", len2);
    _printf("Unknown:[%r]\n");
    printf("Unknown:[%r]\n");
    return (0);
}

OUTPUT:


alex@ubuntu:~/c/printf$ gcc -Wall -Wextra -Werror -pedantic -std=gnu89 -Wno-format *.c
alex@ubuntu:~/c/printf$ ./printf

Let's try to printf a simple sentence.
Let's try to printf a simple sentence.
Length:[39, 39]
Length:[39, 39]
Negative:[-762534]
Negative:[-762534]
Unsigned:[2147484671]
Unsigned:[2147484671]
Unsigned octal:[20000001777]
Unsigned octal:[20000001777]
Unsigned hexadecimal:[800003ff, 800003FF]
Unsigned hexadecimal:[800003ff, 800003FF]
Character:[H]
Character:[H]
String:[I am a string !]
String:[I am a string !]
Address:[0x7ffe637541f0]
Address:[0x7ffe637541f0]
Percent:[%]
Percent:[%]
Len:[12]
Len:[12]
Unknown:[%r]
Unknown:[%r]

AUTHORS C#22 ✒️

Chloé CORREIA and Wilfried LEROULIER

FLOWCHARTS 📈


#️⃣ ONE

_printf_flow_chart

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages