"Failure is not the opposite of success, it's part of it."
I failed the 1337 Piscine.
It hurt. I thought I wasn't cut out for programming. But instead of giving up, I asked myself:
"What if I just kept going anyway?"
So I did. I didn't wait for acceptance. I didn't wait for permission. I grabbed the 42 curriculum, opened up my terminal, and started building libft โ the first project in the 42 network.
No teachers. No peers. Just me, the C documentation, and a lot of segmentation faults.
This repository is proof that you don't need to be accepted into 42 to learn like a 42 student. You just need to start.
libft is a custom implementation of essential C standard library functions. It's the foundation project at 42 School โ designed to teach you:
- ๐ง How C actually works under the hood
- ๐ Pointers and memory management (malloc, free, memory leaks)
- ๐งฑ Modular programming (writing reusable code)
- โ๏ธ Makefiles and compilation pipelines
- ๐ Debugging (valgrind, gdb, and patience)
Instead of relying on <string.h> or <stdlib.h>, you rebuild them yourself. Every function. Every edge case. Every bug.
It's brutal. It's frustrating. And it's exactly what you need to understand C deeply.
ft_isalphaโ checks if character is alphabeticft_isdigitโ checks if character is a digitft_isalnumโ checks if character is alphanumericft_isasciiโ checks if character is ASCIIft_isprintโ checks if character is printableft_toupperโ converts to uppercaseft_tolowerโ converts to lowercase
ft_strlenโ calculates string lengthft_strchrโ locates character in stringft_strrchrโ locates character in string (from the end)ft_strncmpโ compares two strings up to n bytesft_strlcpyโ copies string with size limitft_strlcatโ concatenates string with size limitft_strnstrโ locates substring in stringft_strdupโ duplicates string (malloc)ft_substrโ extracts substringft_strjoinโ concatenates two strings (malloc)ft_strtrimโ trims characters from both endsft_splitโ splits string by delimiter (malloc)ft_itoaโ converts integer to string (malloc)ft_strmapiโ applies function to each characterft_striteriโ applies function to each character (with index)
ft_memsetโ fills memory with constant byteft_bzeroโ zeros out memoryft_memcpyโ copies memory areaft_memmoveโ copies memory (handles overlap)ft_memchrโ locates byte in memoryft_memcmpโ compares memory areasft_callocโ allocates and zeros memory
ft_atoiโ converts string to integer
ft_putchar_fdโ outputs character to file descriptorft_putstr_fdโ outputs string to file descriptorft_putendl_fdโ outputs string + newline to file descriptorft_putnbr_fdโ outputs integer to file descriptor
โ Pointers are not scary โ they're just addresses. Once you understand that, everything clicks.
โ
Memory management is critical โ every malloc needs a free. Valgrind is your best friend.
โ Edge cases matter โ NULL pointers, empty strings, size 0... handle them all.
โ
Makefiles automate builds โ make, make clean, make fclean, make re.
โ
Reading man pages is a superpower โ man 3 strlen teaches you more than any tutorial.
โ Debugging takes patience โ segfaults will test you. Print statements and gdb will save you.
๐ฅ You don't need permission to learn โ failing the Piscine doesn't mean you can't code.
๐ฅ Struggle is growth โ if it's hard, you're learning.
๐ฅ Build in public โ sharing your code makes you accountable and helps others.
๐ฅ Self-teaching is a skill โ no one is coming to save you. Figure it out.
git clone https://github.com/yourusername/libft.git
cd libftmakeThis creates libft.a โ a static library you can link to your projects.
In your C file:
#include "libft.h"
int main(void)
{
char *str = ft_strdup("Hello from libft!");
ft_putendl_fd(str, 1);
free(str);
return (0);
}Compile and link:
gcc -Wall -Wextra -Werror main.c -L. -lft -o program
./programmake clean # removes object files
make fclean # removes object files and libft.a
make re # recompiles everything from scratchI included a comprehensive test file: test_libft.c
make
gcc -Wall -Wextra -Werror test_libft.c -L. -lft -o test_libft
./test_libftYou'll see:
- โ Green checkmarks for passing tests
- โ Red X marks for failing tests
- A final summary with pass/fail count
Use these amazing community testers:
- Tripouille/libftTester โ comprehensive and strict
- jtoty/Libftest โ classic and thorough
- alelievr/libft-unit-test โ detailed output
# Example with Tripouille
git clone https://github.com/Tripouille/libftTester.git
cd libftTester
makeAlways check for leaks:
valgrind --leak-check=full ./test_libftlibft/
โโโ Makefile # Build automation
โโโ libft.h # Header file with function prototypes
โโโ ft_*.c # All function implementations
โโโ test_libft.c # Comprehensive test suite
โโโ README.md # This file
All functions are compiled with:
-Wall -Wextra -WerrorTranslation: No warnings. No compromises. Clean code or it doesn't compile.
This project follows the 42 Norm, which enforces:
- Max 25 lines per function
- Max 5 functions per file
- No
forloops (onlywhile) - Specific naming conventions
- No memory leaks, no segfaults
Use norminette to check:
norminette *.c *.hNow that I've built libft, I'm using it as a foundation for:
- ๐ get_next_line โ reading files line by line
- ๐จ๏ธ ft_printf โ custom printf implementation
- ๐ minishell โ building a bash-like shell
- ๐งฎ push_swap โ algorithm optimization challenges
This is just the beginning.
If you're reading this because you failed Piscine and you're wondering if you should keep going...
Keep going.
You don't need a school to validate your learning. You don't need acceptance to start building. You just need:
- A computer
- A compiler
- The decision to not give up
I failed. I kept coding. And now I have a working C library that I built from scratch.
You can too.
The 42 curriculum is open source. The knowledge is free. The only thing stopping you is you.
So open your terminal, clone this repo, break it, fix it, and make it yours.
Welcome to the real Piscine โ the one that never ends.
Found a bug? Have a suggestion? Want to add a feature?
Feel free to open an issue or submit a pull request. This project is a learning tool โ let's make it better together.
This project is open source and available under the MIT License.
Use it. Learn from it. Build on it.