{"id":18877278,"url":"https://github.com/pedrozappa/42_libft","last_synced_at":"2026-02-18T21:30:14.537Z","repository":{"id":200820237,"uuid":"700332499","full_name":"PedroZappa/42_libft","owner":"PedroZappa","description":"42 Project : Libft","archived":false,"fork":false,"pushed_at":"2024-09-10T14:42:57.000Z","size":1878,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-31T02:21:24.480Z","etag":null,"topics":["42","42born2code","42cursus","42school","c","libft"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PedroZappa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-04T11:55:45.000Z","updated_at":"2024-10-23T15:57:15.000Z","dependencies_parsed_at":"2024-08-17T09:27:15.863Z","dependency_job_id":"adf025d0-04ff-4973-af76-4dea19071c4e","html_url":"https://github.com/PedroZappa/42_libft","commit_stats":null,"previous_names":["pedrozappa/libft","pedrozappa/42_libft"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PedroZappa%2F42_libft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PedroZappa%2F42_libft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PedroZappa%2F42_libft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PedroZappa%2F42_libft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PedroZappa","download_url":"https://codeload.github.com/PedroZappa/42_libft/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239833540,"owners_count":19704628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["42","42born2code","42cursus","42school","c","libft"],"created_at":"2024-11-08T06:17:59.837Z","updated_at":"2026-02-18T21:30:14.484Z","avatar_url":"https://github.com/PedroZappa.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca name=\"readme-top\"\u003e\u003c/a\u003e\n\u003cdiv align=\"center\"\u003e\n\u003ch1\u003elibft 📔\u003c/h1\u003e\n\n\u003cp\u003e( a \u003ca href=\"https://github.com/42School\" target=\"_blank\"\u003e42 School\u003c/a\u003e Project )\u003c/p\u003e\n\n\u003cp\u003e\n    \u003cimg src=\"https://img.shields.io/badge/score-125%20%2F%20100-success?style=for-the-badge\" /\u003e\n    \u003cimg src=\"https://img.shields.io/github/repo-size/PedroZappa/42_libft?style=for-the-badge\u0026logo=github\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/languages/count/PedroZappa/42_libft?style=for-the-badge\u0026logo=\" /\u003e\n    \u003cimg src=\"https://img.shields.io/github/languages/top/PedroZappa/42_libft?style=for-the-badge\" /\u003e\n    \u003cimg src=\"https://img.shields.io/github/last-commit/PedroZappa/42_libft?style=for-the-badge\" /\u003e\n\u003c/p\u003e\n\n___\n\n\u003ch3 align=center\u003eTable o´Contents\u003c/h3\u003e\n\n\u003c!-- mtoc-start --\u003e\n\n* [About 📌](#about-)\n* [Usage](#usage)\n* [Setup \u0026 Compilation 🖇️](#setup--compilation-)\n* [Makefile rules 🔧](#makefile-rules-)\n* [Implementation](#implementation)\n  * [License](#license)\n\n\u003c!-- mtoc-end --\u003e\n\n\u003cdiv/\u003e\n\n\n\n\u003cdiv align=left\u003e\n\n# About 📌\n\nThe first foundational project of the `Common Core` curriculum at 42, `libft`. A learning exploration of the inner workings of standard and non-standard C language functions by developing them from scratch to put together a custom personal library. This is a crucial project as this library will be useful in many of the following projects of the `Common Core`.\n\n\u003e **Disclaimer**: This code base follows a peculiar coding style, to pass [Norminette](https://github.com/42School/norminette)'s' queer syntactical tests, a requirement for most projects at 42 School.\n\n\u003e\u003e ❗ **Important**: If you happen to be a student at 42, you are encouraged to go through the process of writing these functions and testing them yourself. Feel free to use this repository as a research source, but beware of the `copy paste` monster! Do not use code you only understand partially, it will make later projects much harder to manage! If you passed the piscine you should be able to complete this project successfully. Be thorough, be persistent and be patient with yourself!\n\n[libft Subject (English)](/libft.en.subject.pdf)\n\n# Usage\n\n## Setup \u0026 Compilation 🖇️\n\n1. Clone repository:\n\n```sh\ngit clone git@github.com:PedroZappa/42_libft.git\n```\n\n2. Go inside the project folder and run `make`:\n\n```sh\ncd libft\nmake\n```\n\n3. To use the library on your code base `#include` the following header:\n\n```c\n#include \"libft.h\"\n```\n\n___\n## Makefile rules 🔧\n\n- To compile `libft` with **mandatory** files: `make`\n\n- To compile `libft` with **bonus** files: `make bonus`\n\n- To compile `libft` with **ft_printf** **get_nextline** files: `make extra`\n\n- To clean the working directory of **object files** (**.o**): `make clean`\n\n- To clean the working directory of **object files** (**.o**) and **archive** (**.a**) files: `make fclean`\n\n___\n## Implementation\n\nThis project comprises `43` functions divided into three sections:\n- **Mandatory Part 1**, a selection of `23` `libc` functions;\n- **Mandatory Part 2**, `11` more non-standard or modified-standard functions;\n- plus a **Bonus Part**, a final set of `9` functions helpful for manipulating lists;\n\n___\n\n\u003cdetails\u003e\n\t\u003csummary style=\"font-size: 18px; font-weight: bold;\"\u003eMandatory Part 1 📝\u003c/summary\u003e\n\u003cul\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_isalpha\u003c/summary\u003e\n\t\u003cp\u003eChecks if a given character is a letter of the alphabet (a-z or A-Z);\u003cp\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_isdigit\u003c/summary\u003e\n\t\u003cp\u003eChecks if a given character is a digit (0-9);\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_isalnum\u003c/summary\u003e\n\t\u003cp\u003eChecks if a character is alphanumeric (a-z, A-Z or 0-9);\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_isascii\u003c/summary\u003e\n\t\u003cp\u003eChecks if a given character is within the ASCII character set (0-127);\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_isprint\u003c/summary\u003e\n\t\u003cp\u003eChecks if a a given character is within the printing ASCII character set (32-126);\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_strlen\u003c/summary\u003e\n\t\u003cp\u003eCalculates the length of a null-terminated string;\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_memset\u003c/summary\u003e\n\t\u003cp\u003eSets a given block of memory to a specific value/character;\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_bzero\u003c/summary\u003e\n\t\u003cp\u003eSets a given block of memory to zero;\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_memcpy\u003c/summary\u003e\n\t\u003cp\u003eCopies a specified number of bytes from one memory location to another;\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_memmove\u003c/summary\u003e\n\t\u003cp\u003eMoves/Copies a specified number of bytes from one memory location to another, even when the source and destination regions overlap;\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_strlcpy\u003c/summary\u003e\n\t\u003cp\u003eCopies a string with a given length, ensuring that the destination buffer is not overrun; Returns the total length of 'src';\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_strlcat\u003c/summary\u003e\n\t\u003cp\u003eAppends a null-terminated string 'src' to the end of 'dst', appending at most `size - strlen(dst) - 1` bytes, null-terminating the result; Returns the initial length of 'dst' plus the length of 'src';\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_toupper\u003c/summary\u003e\n\t\u003cp\u003eConverts a given character to uppercase;\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_tolower\u003c/summary\u003e\n\t\u003cp\u003eConverts a given character to lowercase;\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_strchr\u003c/summary\u003e\n\t\u003cp\u003eSearches for the first occurrence of a given character in a string, returning a pointer to its location in memory; If no match is found returns NULL;\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_strrchr\u003c/summary\u003e\n\t\u003cp\u003eSearches for the last occurrence of a given character in a string, returning a pointer to its location in memory; If no match is found returns NULL;\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_strncmp\u003c/summary\u003e\n\t\u003cp\u003eCompares two strings up to a given number of characters, returns '0' if they are equal, or returns the difference between the first two characters that do not match;\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_memchr\u003c/summary\u003e\n\t\u003cp\u003eSearches the initial 'n' bytes within a block of memory for a specific byte value, returning a pointer to its location in memory; If no match is found returns NULL;\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_memcmp\u003c/summary\u003e\n\t\u003cp\u003eCompares two strings up to a given number of bytes, returning '0' if they are equal, or returns the difference between the first two characters that do not match;\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_strnstr\u003c/summary\u003e\n\t\u003cp\u003eSearches 'len' characters for the first occurrence of the null-terminated string 'little' in the string 'big'; If 'little' is empty 'big' is returned, if no match is found returns NULL, otherwise returns a pointer to the first character of the first occurrence of 'little' in 'big';\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_atoi\u003c/summary\u003e\n\t\u003cp\u003eConverts the initial portion of the string pointed to by 'nptr' to int; The string may begin with an arbitrary amount of whitespace (as determined by isspace(3)) followed by a single optional'+' or '-' sign. Returns the converted value or '0' on error;\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n        \u003csummary\u003e ✅ ft_calloc\u003c/summary\u003e\n\t\u003cp\u003eAllocates memory for an array of 'nmemb' elements of 'size' bytes each; Returns a pointer to the allocated memory, or NULL if the allocation fails; The memory is set to zero.\u003c/p\u003e\n\u003c/details\u003e\n\u003cdetails\u003e\n\t\u003csummary\u003e ✅ ft_strdup\u003c/summary\u003e\n\t\u003cp\u003eReturns a pointer to a new string, a duplicate of the string pointed to by 's', or NULL if the allocation fails; Memory for the string is obtained with 'malloc(3)', and can be freed using 'free(3)';\u003c/p\u003e\n\n\u003c/details\u003e\n\u003c/ul\u003e\n\u003c/details\u003e\n\n___\n\n\u003cdetails\u003e\n\t\u003csummary style=\"font-size: 18px; font-weight: bold;\"\u003eMandatory Part 2 📝\u003c/summary\u003e\n\t\u003cul\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_substr\u003c/summary\u003e\n\t\t\u003cp\u003eAllocates memory (with malloc(3)) and returns a substring from the string 's'. Starting at index 'start' and is of maximum size 'len'; If allocation fails returns NULL;\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_strjoin\u003c/summary\u003e\n\t\t\u003cp\u003eAllocates memory (with malloc(3)) and returns a new string, which is the result of the concatenation of 's1' and 's2'. If the allocation fails returns NULL;\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_strtrim\u003c/summary\u003e\n\t\t\u003cp\u003eAllocates memory (with malloc(3)) and returns a copy of 's1' with the characters specified in 'set' removed from the beginning and the end of the string; Returns NULL if the allocation fails;\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_split\u003c/summary\u003e\n\t\t\u003cp\u003eAllocates memory (with malloc(3)) and returns an array of strings obtained by splitting 's' using the  chracter 'c' as de limiter. The array must end with a NULL pointer. If allocation fails  returns NULL;\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_itoa\u003c/summary\u003e\n\t\t\u003cp\u003eAllocates memory (with malloc(3)) and returns a string representing the integer received as an argument. Negative numbers must be handled. If allocation fails return NULL;\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_strmapi\u003c/summary\u003e\n\t\t\u003cp\u003eApplies the function ’f’ to each character of the string ’s’, and passing its index as first argument to create a new string (with malloc(3)) resulting from successive applications of ’f’. Returns NULL if the allocation fails;\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_striteri\u003c/summary\u003e\n\t\t\u003cp\u003eApplies the function ’f’ on each character of the string passed as argument, passing its index as first argument. Each character is passed by address to ’f’ to be modified if necessary. Returns nothing;\u003c/p\u003e\n\t\u003c/details\u003e\n        \u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_putchar_fd\u003c/summary\u003e\n\t\t\u003cp\u003eOutputs the character ’c’ to the given file descriptor;\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_putstr_fd\u003c/summary\u003e\n\t\t\u003cp\u003eOutputs the string 's' to the given file descriptor;\u003cp\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_putendl_fd\u003c/summary\u003e\n\t\t\u003cp\u003eOutputs the string 's' followed by a newline to the given file descriptor;\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_putnbr_fd\u003c/summary\u003e\n\t\t\u003cp\u003eOutputs the integer 'n' to the given file descriptor;\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003c/ul\u003e\n\u003c/details\u003e\n\n___\n\n\u003cdetails\u003e\n\t\u003csummary style=\"font-size: 18px; font-weight: bold;\"\u003eBonus Part 📝\u003c/summary\u003e\n\t\u003cul\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_lstnew\u003c/summary\u003e\n\t\t\u003cp\u003eAllocates (with malloc(3)) and returns a new node. The member variable ’content’ is initialized with the value of the parameter ’content’. The variable ’next’ is initialized to NULL.\u003cp\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_lstadd_front\u003c/summary\u003e\n\t\t\u003cp\u003eAdds the node ’new’ at the beginning of the list.\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_lstsize\u003c/summary\u003e\n\t\t\u003cp\u003eCounts the number of nodes in a list.\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_lstlast\u003c/summary\u003e\n\t\t\u003cp\u003eReturns the last node of the list.\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_lstadd_back\u003c/summary\u003e\n\t\t\u003cp\u003eAdds the node ’new’ at the end of the list.\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_lstdelone\u003c/summary\u003e\n\t\t\u003cp\u003eTakes as a parameter a node and frees the memory of the node’s content using the function ’del’ given as a parameter and free the node. The memory of ’next’ must not be freed.\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_lstclear\u003c/summary\u003e\n\t\t\u003cp\u003eDeletes and frees the given node and every successor of that node, using the function ’del’ and free(3). Finally, the pointer to the list must be set to NULL.\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_lstiter\u003c/summary\u003e\n\t\t\u003cp\u003eIterates the list ’lst’ and applies the function ’f’ on the content of each node.\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003cdetails\u003e\n\t\t\u003csummary\u003e ✅ ft_lstmap\u003c/summary\u003e\n\t\t\u003cp\u003eIterates the list ’lst’ and applies the function ’f’ on the content of each node. Creates a new list resulting of the successive applications of the function ’f’. The ’del’ function is used to delete the content of a node if needed.\u003c/p\u003e\n\t\u003c/details\u003e\n\t\u003c/ul\u003e\n\t\u003c/div\u003e\n\u003c/details\u003e\n\n___\n\n### License\n\nThis work is published under the terms of \u003ca href=\"https://github.com/PedroZappa/libft/blob/master/LICENSE\"\u003e42 Unlicense\u003c/a\u003e.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eget to top\u003c/a\u003e)\u003c/p\u003e\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpedrozappa%2F42_libft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpedrozappa%2F42_libft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpedrozappa%2F42_libft/lists"}