libft
is a C library project that aims to recreate some of the C standard library functions, as well as additional utility functions commonly used in programming. This project is part of the 42 coding school curriculum and helps students solidify their understanding of C programming, memory management, and data structures.
- String manipulation functions, such as
ft_strdup
,ft_strjoin
,ft_strncmp
, andft_strtrim
. - Memory management functions, such as
ft_memset
,ft_memcpy
,ft_memmove
, andft_memcmp
. - Linked list data structure implementation with functions for creation, modification, and traversal.
- Integer manipulation functions, such as
ft_itoa
,ft_atoi
, andft_isdigit
. - File descriptor manipulation functions, such as
ft_putchar_fd
,ft_putstr_fd
,ft_putendl_fd
, andft_putnbr_fd
.
- A Unix-based operating system (macOS, Linux, or WSL on Windows)
- GCC compiler
make
utility
- Clone the repository:
git clone https://github.com/JosephKiragu/libft.git
- Change into the project directory:
cd libft
- Compile the project using the provided
Makefile
:
make
- Include the header file
libft.h
in your C source files where you want to use thelibft
functions.
#include "libft.h"
- Use the
libft
functions in your code. Here's an example:
#include "libft.h"
int main(void)
{
char *src = "Hello, World!";
char *dst;
dst = ft_strdup(src);
ft_putstr(dst);
ft_putchar('\n');
free(dst);
return 0;
}
- Compile your program with the libft object files:
gcc -Wall -Wextra -Werror -I./ -o your_program your_program.c libft.a
- Run your program:
./your_program
The project comes with a test suite. To run the tests, follow these steps:
- Compile the test program:
make test
- Run the test program:
./test_libft