ft_printf
is a custom implementation of the standard printf
function in C, handling formatted output with various specifiers.
- Format Specifiers:
%c
- Prints a single character.%s
- Prints a string (as defined by the common C convention).%p
- The void * pointer argument has to be printed in hexadecimal format.%d
- Prints a decimal (base 10) number.%i
- Prints an integer in base 10.%u
- Prints an unsigned decimal (base 10) number.%x
- Prints a number in hexadecimal (base 16) lowercase format.%X
- Prints a number in hexadecimal (base 16) uppercase format.%%
- Prints a percent sign.
To get started with this project, simply clone the repository to your local machine:
git clone https://github.com/Mouad-El-Asri/ft_printf.git
Once you've cloned the repository, you can compile the ft_printf
project by following these steps:
-
Navigate to the project directory:
cd ft_printf
-
Compile the project using
make
:make
-
To test your implementation, you can include
ft_printf
in your C programs:#include "ft_printf.h" int main() { ft_printf("Hello, World! %d\n", 42); return 0; }
-
You can then compile and run your program:
gcc main.c -L . -l ftprintf ./a.out
Hereโs a basic example demonstrating how ft_printf
works:
#include "ft_printf.h"
int main() {
int num = 1234;
char c = 'A';
ft_printf("This is a number: %d\n", num);
ft_printf("This is a character: %c\n", c);
return 0;
}
Output:
This is a number: 1234
This is a character: A
This project is licensed under the MIT License - see the LICENSE file for details.
This project is part of the 42 Network curriculum.