Skip to content

leandrobbj/libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Libft  language makefile 42

This project has been created as part of the 42 curriculum by lbraga.

Libft is the first project in the 42 curriculum. The goal is to create the libft.a static library by reimplementing some functions from the standard C library and a few additional utility functions. This project focuses on understanding how these functions work under the hood, handling memory management, string manipulation, and linked lists in the bonus part.

  1. Libft Functions
  2. Instructions
  3. Resources
  4. AI Disclosure
  5. Final Notes
  6. Function List

Libft Functions

  • Characters: isalpha isdigit isalnum isascii isprint toupper tolower
  • Memory: memset bzero memcpy memmove memchr memcmp calloc
  • Strings: strlen strlcpy strlcat strncmp strchr strrchr strnstr strdup substr strjoin strtrim split strmapi striteri
  • Conversion: atoi itoa
  • File Descriptor: putchar_fd putstr_fd putendl_fd putnbr_fd
  • Linked Lists (bonus): lstnew lstadd_front lstsize lstlast lstadd_back lstdelone lstclear lstiter lstmap
  • List Struct:
     typedef struct s_list
     {
     	void			*content;
     	struct s_list	*next;
     }					t_list;
    

Instructions

To compile the library, you must have the cc compiler and the make tool installed.

  1. Clone the repository:

    git clone https://github.com/leandrobbj/libft.git && cd libft
    
  2. Create the library:

    make
    

Other commands:

  • make bonus: Creates the library including the bonus functions.
  • make clean: Removes the object files (.o).
  • make fclean: Removes the object files and the compiled library (libft.a).
  • make re: Performs a fclean followed by a make.

Resources

AI Disclosure

In compliance with the 42 curriculum requirements, I used AI tools, including the CS50.ai Duck, during the development of this project to support my learning. These tools were used to research and summarize technical articles about memory management, pointer arithmetic, recursion, and data structure iteration.

The AI also helped with test development to identify potential logic bugs and edge cases during the implementation of complex functions, and supported the organization and formatting of project configuration files.

Final Notes

Developing Libft was a significant challenge that helped me understand the standard functions from scratch. This project gave me a foundation in pointer arithmetic for direct memory manipulation and in working with pointers to pointers. Ultimately, it was about building the skills needed to solve problems and create a reliable toolkit for future projects.

This is the end of the documentation. For a quick reference on how each function behaves, please refer to the List below.

Function List

Libc Functions Description
isalpha Checks for an alphabetic character.
isdigit Checks for a digit (0 through 9).
isalnum Checks for an alphanumeric character.
isascii Checks whether c fits into the ASCII character set.
isprint Checks for any printable character.
strlen Calculates the length of a string.
memset Fills memory with a constant byte.
bzero Erases the data in n bytes of memory.
memcpy Copies memory area.
memmove Copies memory area (handles overlapping).
strlcpy Size-bounded string copying.
strlcat Size-bounded string concatenation.
toupper Converts a lowercase letter to uppercase.
tolower Converts an uppercase letter to lowercase.
strchr Locates a character in a string.
strrchr Locates a character in a string, searching from the end.
strncmp Compares two strings up to n characters.
memchr Scans memory for a character.
memcmp Compares memory areas.
strnstr Locates a substring in a string, searching up to n characters.
atoi Converts a string to an integer.
calloc Allocates memory and initializes it to zero.
strdup Creates a duplicate of a string using malloc.
Additional Functions Description
substr Returns a substring from a string.
strjoin Concatenates two strings into a new one.
strtrim Trims specific characters from the start and end of a string.
split Splits a string into an array of strings using a delimiter.
itoa Converts an integer to a string.
strmapi Applies a function to each character of a string to create a new one.
striteri Applies a function to each character of a string by its index.
putchar_fd Outputs a character to a specific file descriptor.
putstr_fd Outputs a string to a specific file descriptor.
putendl_fd Outputs a string followed by a newline to a file descriptor.
putnbr_fd Outputs an integer to a specific file descriptor.
Linked Lists Bonus Functions Description
lstnew Creates a new list element.
lstadd_front Adds an element to the beginning of a list.
lstsize Counts the number of elements in a list.
lstlast Returns the last element of a list.
lstadd_back Adds an element to the end of a list.
lstdelone Deletes one element from a list using a given function.
lstclear Deletes and frees an entire list.
lstiter Iterates through a list and applies a function to each element.
lstmap Iterates through a list and applies a function to create a new list.

About

A custom C library containing implementations of functions from the 42 School curriculum.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors