Skip to content

librity/ft_libft

Repository files navigation

42 São Paulo - libft

42 São Paulo License Code size in bytes Lines of code Top language Last commit

Build Norminette v3

A reasonably-complete implementation of stdlib.h, and much much more.


📜 Table of Contents

🧐 About

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 floats and long doubles. 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.

🏁 Getting Started

⚙️ Prerequisites

All you need is a shell and a C compiler like gcc or clang.

🖥️ Installing

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

🎈 Usage

You can call most stdlib.h functions as you normally would but with the prefix ft_:

ft_putstr("Hello, world!\n");

✅ Tests

This project is partly tested with the Unity framework. To run all tests, run make's test rule:

make tests

✅ To Do

  • 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()

🐙 Github Actions

Norminette Github Action by @AdrianWR

🛸 42 São Paulo

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.