libft

The first brick

The first project of the cursus: rewriting part of the C standard library from its man pages, then adding what it does not provide, string splitting, integer conversion, linked lists. It all compiles into libft.a, linked by every project that came after.

Area
  • 42
  • library
  • c
Stack
C, Makefile
Grade
125%
Date
2021

My first project at 42: rebuilding a chunk of the C standard library, plus a set of utility functions reused by everything that came after.

What it contains

  • Standard library functions rewritten from their man pages and prefixed ft_: strlen, memcpy, memmove, strlcpy, strnstr, atoi, and the is* character tests.
  • Functions the standard library does not provide, or provides differently: substr, strjoin, strtrim, split, itoa, strmapi, striteri, and the putchar_fd family.
  • A bonus set for singly linked lists: lstnew, lstadd_front, lstadd_back, lstsize, lstlast, lstdelone, lstclear, lstiter, lstmap.

What it taught me

Reading a man page as a specification and matching it exactly, return values and edge cases included. Everything compiles into libft.a and gets linked by the later projects, so a bug written here surfaces months later, in code that has nothing to do with it.