This project aims to recreate the printf function in C.
It will handle some basic cases.
#Content
The function _printf will replicate and handle some of the basic case specifiers from the C printf function and some advanced like hexa decimal, octal, and address conversions.
Basic Format Specifiers: Currently supports %s (strings), %c (characters), and %d %i (integers).
More Format Specifiers: Supports %x %X (hexadecimal),%u (unsigned integers), %o (octal).
Include all the files present in the repository.
my_printf.c --- Contains _printf function.
main.h --- All necessary headers and prototypes.
num_functions.c --- Has all functions that handle number cases.
char_funtcions.c --- Has all functions that handle character cases.
Once you have all files remember to include main.h in your .c file :
#include "main.h"To use the function simply call it by giving a format string with case specifiers and can be followed by arguments like this :
int total_len = _printf("Hello %s I am %d years old \n", "there", 1000);
_printf("Total characters printed: %d\n", total_len);Example of using the _printf function:
#include "main.h"
int main() {
char str = "there"
_printf("Hello %s", str);
return (0);
}output:
Hello there