The Libft project involves creating a C library that contains standard C library functions (libc) along with other utility functions. This library will serve as a foundational tool for your future C programming projects at school. It includes functions for string manipulation, memory handling, and linked list management.
- Reimplement a set of standard C library functions.
- Develop additional utility functions that are not available in libc.
- Learn dynamic memory management in C.
- Understand and utilize linked list structures.
- Create a reusable library for future projects.
-
Part 1 - Libc Functions:
- Implementation of functions like
ft_strlen,ft_memset,ft_strchr, etc., which mimic the behavior of standard libc functions.
- Implementation of functions like
-
Part 2 - Additional Functions:
- Utility functions such as
ft_substr,ft_strjoin,ft_split, which are either not available in libc or exist in a different form.
- Utility functions such as
-
Bonus Part:
- Linked list management functions like
ft_lstnew,ft_lstadd_front,ft_lstsize, etc.
- Linked list management functions like
-
Compile the library:
make
-
Clean object files:
make clean
-
Remove all generated files, including the library:
make fclean
-
Recompile everything from scratch:
make re
-
Include bonus functions:
make bonus
To use the library in your project, include the libft.h header file and compile your program with the libft.a library:
#include "libft.h"
int main(void) {
// Example usage
char *str = ft_strdup("Hello, Libft!");
ft_putstr_fd(str, 1);
free(str);
return (0);
}To compile a program using Libft:
gcc -Wall -Wextra -Werror -L[path_to_libft.a] -lft your_program.c -o your_program