+
Skip to content

🚀 Libft implementation, the first 1337/42 project. A custom C library re-creating core functions — memory, strings, chars, and linked lists 🔗. Designed to master low-level programming, memory management, and build a strong foundation for future 42 projects. 💪🔥

Notifications You must be signed in to change notification settings

Frontendab/42-Libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42-Libft

Your very first own C library.

A foundational project at 42 School, aimed at re-coding essential C standard library functions and learning how to build your own reusable library.

Celebrating

📘 Introduction

The Libft project is about creating your own C library that re-implements many of the functions you will use throughout your future projects. It helps you understand the inner workings of common C functions, memory handling, and linked lists — building a strong foundation for low-level programming.

Someone lost in C pointers 😵‍💫

Someone lost in C pointers

libft/
├── .github/workflows
│           └── run-test.yaml
├── Makefile
├── includes/
│   └── libft.h
├── src/
│   ├── Mandatory/
│   │   ├── *.c
│   └── Bonus/
│       ├── *.c
└── README.md

🧾 Common Instructions

  • Your project must follow 42’s Norm (norminette).

  • Your functions must not crash (no segfaults, double frees, or memory leaks).

  • All dynamically allocated memory must be properly freed.

  • You must include a Makefile with at least the rules:

    NAME, all, clean, fclean, re
  • The bonus part should be compiled with:

    make bonus
  • You are encouraged to create and use test programs for your own validation.

When the norminette says OK ✅ 😂

When the norminette says OK ✅

🧱 Mandatory Part

Requirement Details
Library Name libft.a
Files to turn in *.c, libft.h, Makefile
Compiler cc
Flags -Wall -Wextra -Werror
No global variables ✅ Required
Create archive with ar (not libtool)

🧩 Part 1 – Libc Functions

Re-code the following C standard library functions (without using restrict):

  isalpha   isdigit   isalnum   isascii   isprint
  strlen    memset    bzero     memcpy    memmove
  strlcpy   strlcat   toupper   tolower   strchr
  strrchr   strncmp   memchr    memcmp    strnstr
  atoi

And using malloc:

  calloc    strdup

malloc never returns NULL… right? 😅

Coding Rage

🧰 Part 2 – Additional Functions

Functions that are not in libc or have modified behavior:

Function Description
ft_substr Returns a substring from a string.
ft_strjoin Concatenates two strings.
ft_strtrim Trims characters from the beginning and end of a string.
ft_split Splits a string using a delimiter.
ft_itoa Converts an integer to a string.
ft_strmapi Applies a function to each character of a string (creates a new string).
ft_striteri Applies a function to each character of a string (in-place).
ft_putchar_fd Outputs a character to a file descriptor.
ft_putstr_fd Outputs a string to a file descriptor.
ft_putendl_fd Outputs a string followed by a newline.
ft_putnbr_fd Outputs an integer to a file descriptor.

🧩 Bonus Part

Once you’ve completed the mandatory part, you can implement linked list functions.

🧱 Struct Definition

typedef struct s_list
{
    void            *content;
    struct s_list   *next;
} t_list;

🔗 Bonus Functions

Function Description
ft_lstnew Creates a new list node.
ft_lstadd_front Adds a node at the beginning.
ft_lstsize Returns the number of nodes.
ft_lstlast Returns the last node.
ft_lstadd_back Adds a node at the end.
ft_lstdelone Frees a single node.
ft_lstclear Frees an entire list.
ft_lstiter Iterates over a list and applies a function.
ft_lstmap Creates a new list by applying a function to each node.

To compile with the bonus part:

make bonus

Linked list chaos 🪢😂

Linked list chaos 🪢😂)

🧪 Compilation Examples

# Compile the library
make

# Compile the bonus functions
make bonus

# Clean object files
make clean

# Remove binaries and library
make fclean

# Recompile from scratch
make re

# Build and run test program
make test

Makefile says Done compiling 😁👍

Makefile says Done compiling 😁👍

🧰 Test the Norminette or Build via GitHub Actions

If you want to check your code’s Norminette or Build automatically through GitHub:

  1. Go to your repository on GitHub.
  2. Click on the "Actions" tab.
  3. Find the workflow named “Check the Norminette or Build of the code”.
  4. Click “Run workflow”.
  5. In the dropdown, select the typeChoose the type of test?.
  6. Click “Run workflow” again.

GitHub Actions will automatically test your code against the Norminette or Build rules and display the result in the Actions panel ✅.

Waiting for CI to pass ⏳🤞

Waiting for CI to pass ⏳🤞

🧠 Tips

  • Test your functions one by one before adding them to the library.
  • Keep helper (static) functions internal — don’t expose them in libft.h.
  • Check memory leaks.
  • Expand your Libft as you progress — it’s your foundation for future 42 projects.

🏁 Final Goal

By the end of this project, you will:

  • Understand how the C standard library works internally
  • Have a custom reusable C library for all future projects
  • Master memory management, string manipulation, and linked list operations

💬 Author

Made with ❤️ as part of the 42 School Curriculum

“Understanding the foundation of C is the first step toward mastering programming.”

Thanks for reading 🙌

Thanks for reading 🙌

About

🚀 Libft implementation, the first 1337/42 project. A custom C library re-creating core functions — memory, strings, chars, and linked lists 🔗. Designed to master low-level programming, memory management, and build a strong foundation for future 42 projects. 💪🔥

Topics

Resources

Stars

Watchers

Forks

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载