Libft is a project that involves creating a custom C library containing a collection of essential functions that will be useful for future C programming assignments. By implementing these functions, I have gained a deeper understanding of standard C library functions and memory management.
- Standard Library Implementations:
- Reimplementation of standard
libc
functions (e.g.,strlen
,memset
,strchr
). - Functions for character classification (
isalpha
,isdigit
, etc.). - Memory manipulation functions (
memcpy
,memmove
, etc.).
- Reimplementation of standard
- Additional Utility Functions:
- String manipulation (
ft_substr
,ft_strjoin
,ft_strtrim
). - Number to string conversion (
ft_itoa
). - String iteration and transformation (
ft_strmapi
,ft_striteri
). - File descriptor-based output (
ft_putchar_fd
,ft_putstr_fd
, etc.).
- String manipulation (
- Linked List Manipulation:
- Creating and managing linked lists (
ft_lstnew
,ft_lstadd_front
, etc.). - Iterating and modifying linked lists (
ft_lstiter
,ft_lstmap
). - Clearing and freeing list nodes (
ft_lstdelone
,ft_lstclear
).
- Creating and managing linked lists (
- C Compiler: Ensure a compatible compiler (e.g., gcc) is installed.
- Makefile: Provided for efficient compilation.
- Clone this repository:
git clone https://github.com/ejarvinen/42Libft.git
cd 42Libft
- Build the library (without bonus features):
make
- OR build the library (with bonus features):
make bonus
To use libft.a
in your project:
gcc -Wall -Wextra -Werror your_program.c -L. -lft -o your_program
- Norm Compliance: Follows the 42 coding norm.
- Memory Management: Properly frees all heap-allocated memory to avoid leaks.
- Error Handling:
- Ensures functions return expected outputs.
- Handle invalid inputs gracefully.
- Makefile: Handles compilation and cleaning tasks.
- Source Files: Includes
.c
and.h
files for implementation. - Library Archive:
libft.a
for linking with other projects.
#include "libft.h"
#include <stdio.h>
int main() {
char *str = ft_strdup("Hello, Libft!");
printf("%s\n", str);
free(str);
return 0;
}