Skip to content

PereDeMacron/holbertonschool-printf

Repository files navigation

Print-F Project

Holberton School Logo

UBUNTUC

Description

This project is to recreate the printf function in C with its most important features, it was made in the software development program of Holberton School.

Man page

The man page is a file wich explains in detail how the function works. If you want see a full explanation of this function you can run our man page this way:

$ man ./man_3_printf

Flowchart

Flowchart

Usage

Syntaxis
#include <stdio.h>
#include <stdarg.h>

int _printf(const char *format, ...);

Compilation

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


Supported Conversion Specifiers
  • %c : Prints a character.
  • %s : Prints a string of characters.
  • %i & %d : Prints a signed integer in base 10.
  • %% : Prints a literal % character.

Utilisation Exemple

#include <stdio.h>

int _printf(const char *format, ...);

int main()
{
    char ch = 'A';
    char str[] = "Hello, World!";
    int num = 42;

    // Test of the %c specifier
    _printf("Character: %c\n", ch);

    // Test of the %s specifier
    _printf("String: %s\n", str);

    // Test of the %i specifier
    _printf("Number: %i\n", num);

    // Test of the %% specifier
    _printf("Percent sign: %%\n");

    // Test of multiple specifiers in the same string
    _printf("Character: %c, String: %s, Number: %i\n", ch, str, num);

    // Test with an empty string
    _printf("Empty string: %s\n", "");

    // Test with a null character (empty string)
    char empty_str[] = {0};
    _printf("Empty string: %s\n", empty_str);

    return (0);
}

Outpout :

Character: A
String: Hello, World!
Number: 42
Percent sign: %
Character: A, String: Hello, World!, Number: 42
Empty string:
Empty string:

Authors 🤜🤛

  • Raphael Schopfer github
  • Gary Mirambet github
  • C#21 BDX-THO heart

License

This program is distributed under the terms of the Holberton license.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages