Skip to content

printf is a custom function in the C that allows you to print formatted data to the console or a file.

Notifications You must be signed in to change notification settings

khalid1sey/printf

Repository files navigation

0x11. C - printf

_printf - Custom Print Function

The _printf function is a custom print function in C that supports various format specifiers. It allows for flexible printing of characters, strings, integers, decimals, and binary numbers.

Function Signature c

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

unction Parameters

format: A pointer to a character array (const char*) representing the format string that specifies the desired output format.
...: Variadic arguments that correspond to the format specifiers in the format string.

Supported Format Specifiers

Here are some commonly used format specifiers in printf:
specifier: description
%c: Format as a character.
%s: Format as a null-terminated string.
%i: Format as a signed integer.
%d: Format as a signed decimal.
%b: Format as Unsigned binary.
%u : Format as an unsigned decimal integer.
%o: Format as an octal.
%x: Format as a hexadecimal number, lowercase.
%X: Format as a hexadecimal number, uppercase.
%p: Format as a pointer.

Source Files

The implementation of the _printf function is divided into multiple source files:

Conversion Specifier Structure

The conversioThe conversion_specifier structure has the following members:
specifier: A pointer to a character (char*) that represents the format specifier.
fptr: A pointer to a function (int (*)()) that takes no arguments and returns an integer.

print_formats.c

print_char: Function to handle printing a character.
print_string: Function to handle printing a string.
print_37: Function to handle printing a percent specifier.
print_int: Function to handle printing signed decimal integers.
print_decimal: Function to handle printing unsigned decimal integers.

print_formats2.c

print_binary: Function to handle printing a binary representation of an unsigned integer.

helpers.c

_putchar: Function to print a character to the standard output.
_puts: Function to print a null-terminated string to the standard output.

Purpose

The _printf function provides a customizable and extensible print function in C, similar to the standard printf function. It allows for printing different data types and format specifiers, providing flexibility and control over the output format.

Authors

Khalid Sinteayehu lilahseyfu@gmail.com

About

printf is a custom function in the C that allows you to print formatted data to the console or a file.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published