My implementation of some of the Standard C Library functions including some additional ones.
Libft is an individual project at 1337 that requires us to re-create some standard C library functions including some additional ones that can be used later to build a library of useful functions for the rest of the program.
Disclaimer: Reinventing the wheel is bad, 42 makes us do this just so we can have a deeper understanding of data structures and basic algorithms. At 42 we're not allowed to use some standard libraries on our projects, so we have to keep growing this library with our own functions as we go farther in the program.
- Libc Functions: Some of the standard C functions
- Additional functions: Functions 42 deems will be useful for later projects
- Bonus Functions: Functions 42 deems will be useful for linked list manipulation
Notes:
- Most of the the files and function names are namespaced with an ft in front. It stands for Fourty Two
- I update this list almost every month with new personal functions. If you don't know what a function does, refer to the man My code is not the best, but it passed all the 42 tests successfully.
The goal is to create a library called libft.a from the source files so I can later use that library from other projects at 42.
To create that library, after downloading/cloning this project, cd into the project, copy all the files from the sub folders to the root directory and finally, call make:
git clone https://github.com/KD-ayoub/libft
cd libft
make copy
make
You should see a libft.a file and some object files (.o).
Now to clean up (removing the .o files and the .c files from the root), call make clean
I added an example file called example.c, it's using the function ft_putstr to print "DON'T PANIC" to the screen.
If you try to compile it with gcc using gcc example.c you will get an undefined symbol error for ft_putstr.
You have to tell the file where your library resides and which library it is using:
gcc example.c libft.a
That's it. Now run it using ./a.out
To test the code we're going to be using @alelievr's Libft Unit Test.
-
Clone this repo and cd into it, make sure it's called
libft:git clone https://github.com/KD-ayoub/libft cd libft/ -
Run Make so you can build the library:
make -
Go back to the root directory and download @alelievr's Libft Unit Test:
cd .. git clone https://github.com/alelievr/libft-unit-test -
Go into the test folder and run the test:
cd libft-unit-test/ make f
If you did everything correctly you should get a cool list of tests showing you the function names and if they passed or not.
Enjoy.