Write a function that produces output according to a format (reference: Printf function).
_printf is a custom implementation of the C standard library's printf function. The goal of this project is to recreate the functionality of printf in a way that is clear, concise, and easily extensible. This implementation supports many of the features of printf, including formatting of strings, numbers, and other data types, as well as the ability to print to standard output and files.
- Makefile: Makefile that contains the compiler, the clean method, etc.
- Header: The header file, contains all prototipes's functions, and the libraries use it in the project.
- Tests: The folder of tests, contains all tests files.
- Base Functions: C file that contains the functions that change a int to another numerical system.
- The base of the function: The principal function.
- Write Char: Writes the character c to stdout.
To use the _printf function, include the "main.h" header file in your C program and call the function using the following syntax:
_printf(format, arguments...)
The format string is a character string that specifies how the arguments following it should be formatted and printed. The arguments can be of any data type supported by printf.
_printf supports the following format specifiers:
%c
: Prints a single character.%s
: Prints a string of characters.%d
: Prints integers.%i
: Prints integers.%b
: Prints the binary representation of an unsigned decimal.%u
: Prints unsigned integers%r
: Prints a reversed string%%
: Prints a percentage
Here are some examples of how to use _printf:
#include "main.h"
int main(void)
{
_printf("Hello, world!\n");
_printf("The first 10 prime numbers are: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", 2, 3, 5, 7, 11, 13, 17, 19, 23, 29);
_printf("Printing a string: %s\n", "Hi, How are you?");
_printf("Printing a percentage: %%\n");
return (0);
}
If you find any bug, please, let us know.
All files have been written in the Betty Style.