This project remakes some usual C language functions and adds a few new ones that will help students. The main goal is to make a set of functions that can be used again in later work, so students don't have to write them from scratch each time. This set of functions will be needed for most projects at 42. the project is a great opportunity to improve your skills in C programming and to learn about the structure of a library.
The project contains 2 parts: Mandatory and Bonus. you need also to create a Makefile that compiles the library and a libft.h file which outputs an archive called libft.a.
Mandatorypart contains functions fromLibcandAdditionalones that are useful for everyday programming.Bonuspart contains functions that are useful for linked list manipulation.
to get started with using libft, clone the repository and compile the library using the provided Makefile.
git clone https://github.com/whoismtrx/42_Libft.git libft
cd libft
make
to use the library in your project, include the libft.h header file in your source code and link the library when compiling.
// example.c
#include "libft.h"
cc example.c libft.a -o example
- ft_isalpha: checks if the character is an alphabetic character.
- ft_isdigit: checks if the character is a digit.
- ft_isalnum: checks if the character is an alphanumeric character.
- ft_isascii: checks if the character is a 7-bit ASCII character.
- ft_isprint: checks if the character is a printable character.
- ft_strlen: calculates the length of a string.
- ft_memset: fills a block of memory with a byte value.
- ft_bzero: writes zeros to a byte string.
- ft_memcpy: copies memory area from source to destination.
- ft_memmove: copies memory area with overlapping memory blocks.
- ft_strlcpy: copies a string to a fixed-size buffer.
- ft_strlcat: appends a string to a fixed-size buffer.
- ft_toupper: converts a lowercase letter to uppercase.
- ft_tolower: converts an uppercase letter to lowercase.
- ft_strchr: locates the first occurrence of a character in a string.
- ft_strrchr: locates the last occurrence of a character in a string.
- ft_strncmp: compares two strings up to a certain number of characters.
- ft_memchr: locates the first occurrence of a character in a memory block.
- ft_memcmp: compares two memory blocks.
- ft_strnstr: locates a substring in a string.
- ft_atoi: converts a string to an integer.
- ft_calloc: allocates memory for an array and initializes it with zeros.
- ft_strdup: duplicates a string in memory with allocation.
- ft_substr: allocates and returns a substring from a string.
- ft_strjoin: concatenates two strings into a new string.
- ft_strtrim: trims the beginning and end of a string with a set of characters.
- ft_split: splits a string into an array of strings using a delimiter character.
- ft_itoa: converts an integer to a string.
- ft_strmapi: applies a function to each character of a string to create a new string.
- ft_striteri: applies a function to each character of a string with its index.
- 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 to a file descriptor followed by a newline.
- ft_putnbr_fd: outputs an integer to a file descriptor.
- ft_lstnew: creates a new element for a linked list.
- ft_lstadd_front: adds a new element at the beginning of a linked list.
- ft_lstsize: counts the number of elements in a linked list.
- ft_lstlast: returns the last element of a linked list.
- ft_lstadd_back: adds a new element at the end of a linked list.
- ft_lstdelone: deletes an element from a linked list.
- ft_lstclear: deletes all elements from a linked list.
- ft_lstiter: applies a function to each element of a linked list.
- ft_lstmap: applies a function to each element of a linked list to create a new list.
libft/
├── include/
│ └── libft.h
├── src/
│ ├── ft_*.c (all function implementations)
├── Makefile
└── README.md
As a student, you can use the following resources to help you understand the C Language and the project better:
C Language: this playlist on C Language Tutorial will help you understand more than the basics of the C language.Pointers: this video on Pointers in C/C++ from freeCodeCamp will help you understand pointers in C.Libc functions: you can find more information about these functions in themanpages visit the man7.org or type on your terminalman strlen or man 3 strlenLinked Lists: this video on Linked Lists Introduction from WilliamFiset will help you understand them and how to manipulate them. if you want to learn more about Doubly Linked lists, you can see the part two.Makefile: look at EASY MAKEFILES
This repository is for educational purposes only, documenting my work on the 42 curriculum. These solutions are intended as a reference for students who have already completed or are actively working on the project.