A reasonably-complete implementation of stdlib.h
,
and much much more.
This was my first project at 42 São Paulo:
an implementation of many stdlib.h
functions from scratch.
I've used it on most projects so far. I learned about memory manipulations, string utilities and linked lists. As a developer I've been using these functions for years in some form or another, yet I had no idea how they really work. Figuring them out was an initiation of sorts.
It has over 300 functions so far,
including a heap-less printf
that handles float
s and long double
s.
All functions have a doxygen-style documentation comment,
and most have an example main.
I prioritize modularity and readability:
small functions with catchy names that do one thing well.
All you need is a shell and a C compiler like gcc
or clang
.
To compile the entire thing just clone the repo and run make
:
$ git clone https://github.com/librity/ft_libft.git
$ cd ft_libft
$ make
This will generate a libft.a
archive, which you can compile with
any of the example files:
$ cp examples/ft_itoa.c examples/example.c
$ gcc -g -I ./includes examples/example.c libft.a
$ ./a.out
You can call most stdlib.h
functions as you normally would
but with the prefix ft_
:
ft_putstr("Hello, world!\n");
This project is partly tested with the
Unity framework.
To run all tests, run make
's test
rule:
make tests
- Implement missing
stdlib.h
functions-
atof()
-
atoi()
-
atol()
-
atoll()
-
strtod()
-
strtof()
-
strtol()
-
strtold()
-
strtoll()
-
strtoul()
-
strtoull()
-
rand()
-
srand()
-
calloc()
-
free()
-
malloc()
-
realloc()
-
abort()
-
atexit()
-
at_quick_exit()
-
exit()
-
getenv()
-
quick_exit()
-
system()
-
_Exit()
-
bsearch()
-
qsort()
-
abs()
-
div()
-
labs()
-
ldiv()
-
llabs()
-
lldiv()
-
mblen()
-
mbtowc()
-
wctomb()
-
mbstowcs()
-
wcstombs()
-
Norminette Github Action by @AdrianWR
Part of the larger 42 Network, 42 São Paulo is a software engineering school that offers a healthy alternative to traditional education:
- It doesn't have any teachers and classes.
- Students learn by cooperating and correcting each other's work (peer-to-peer learning).
- Its focus is as much on social skills as it is on technical skills.
- It's completely free to anyone that passes its selection process - The Piscine
It's an amazing school, and I'm grateful for the opportunity.