summaryrefslogtreecommitdiff
path: root/README
diff options
context:
space:
mode:
authoryctct <yctct@yctct.com>2026-02-05 11:56:49 +0100
committeryctct <yctct@yctct.com>2026-02-05 11:56:49 +0100
commit861a36d86e7587c043131228cf3a08afd7bc43ad (patch)
treea931df9f1845250c0e93adeda52f139c2f5ee1b0 /README
Add files, first commit
Diffstat (limited to 'README')
-rw-r--r--README242
1 files changed, 242 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..3140f92
--- /dev/null
+++ b/README
@@ -0,0 +1,242 @@
+Libft
+====
+
+Description
+----------
+
+This repository carries selected functions replicated from The GNU C Library,
+`glibc` , additional functions that are not included in `glibc` as well as
+functions dealing with linked lists.
+
+Scroll down for a list and description of each of the functions.
+
+The motivation for writing this library is to learn C, and to have a set of
+functions I will use for future C projects.
+
+Instructions
+------------
+
+To clone this repository of this library run:
+
+ $ git clone https:/git.yctct.com/libft libft $ cd libft
+
+To compile the library run:
+
+ $ make
+
+To recompile the library run:
+
+ $ make re
+
+To delete all object files run:
+
+ $ make clean
+
+To delete all object files and libft.a run:
+
+ $ make fclean
+
+Add #include "path/to/libft.h" at the top of your \*.c files.
+
+Resources
+--------
+
+- man pages: ascii, limits.h and all the man pages of functions that are
+ replicated in this library.
+
+On libraries:
+
+- [C Libraries](https://www.cs.swarthmore.edu/~newhall/unixhelp/howto_C_libraries.html)
+
+On makefiles:
+
+- [Makefiles](https://www.cs.dartmouth.edu/~cs50/Lectures/makefiles/)
+- [A Simple Makefile Tutorial, Bruce A.
+ Maxwell](https://cs.colby.edu/maxwell/courses/tutorials/maketutor/)
+- the man pages of `make` and `ar`
+
+On malloc:
+
+- [Dynamic Memory
+ Allocation](https://www.cs.cornell.edu/courses/cs3410/2025fa/rsrc/c/malloc.html)
+- [Malloc: Allocating Memory in C, Mia
+ Combeau](https://www.codequoi.com/en/malloc-allocating-memory-in-c/)
+
+On linked list and struct:
+
+- [Beej's Guide to C programming, chapter 8, Struct, 2025 Brian “Beej
+ Jorgensen” Hall](https://beej.us/guide/bgc/html/#structs)
+- [Zeste de Savoir, Les
+ structures](https://zestedesavoir.com/tutoriels/755/le-langage-c-1/1043_aggregats-memoire-et-fichiers/4279_structures/#1-12828_definition-initialisation-et-utilisation)
+- Practical C, Steve Oualline, O'Reilly, 3rd edition
+
+On Markdown:
+
+- [Markdown, John Gruber](https://daringfireball.net/projects/markdown/) which
+ as a script to convert Markdown to HTML
+
+
+Description of functions
+-------------------------
+
+**Functions from `libc`**
+
+`libft.h`: contain all the prototypes, libraries needed and struct.
+
+`Makefile`: contain all the rules to compile, recomplie and clean.
+
+`ft_isalpha`: checks if all characters in a given string are is alphabetical.
+
+`ft_isdigit`: checks if all characters in a given string are digits.
+
+`ft_isalnum`: checks if all characters in a given string are alphabetical or
+digits .
+
+`ft_isascii`: checks if an integer is within the range of ascii value.
+
+`ft_isprint`: checks if an integer is within the range of printable ascii
+value.
+
+`ft_strlen`: calculates the length of a given string .
+
+`ft_memset`: fills the first n bytes of a memory area with a constant c.
+
+`ft_bzero`: fills the first n bytes of a memory area with '0'.
+
+`ft_memcpy`: copies n bytes from a memory area src to memory dest.
+
+`ft_memmove`: copies n bytes from a memory area src to memory dest, memory
+areas may overlap.
+
+`ft_strlcpy`: copies up to size - 1 characters from the NUL-terminated string
+src to dst, NUL-terminating the result.
+
+`ft_strlcat`: appends the NUL-terminated string src to the end of dst. It will
+append at most size - strlen(dst) - 1 bytes, NUL-terminating the result.
+
+`ft_toupper`: converts lowercase letters to uppercase.
+
+`ft_tolower`: converts uppercase letters to lowercase.
+
+`ft_strchr`: returns a pointer to the first occurrence of the character c in
+the string s.
+
+`ft_strrchr`: returns a pointer to the last occurrence of the character c
+in the string s.
+
+`ft_strncmp`: compares the first (at most) n bytes of strings s1 and s2.
+
+`ft_memchr`: scans the initial n bytes of the memory area pointed to by s for
+the first instance of c.
+
+`ft_memcmp`: compares the first n bytes (each interpreted as unsigned char) of
+the memory areas s1 and s2.
+
+`ft_strnstr`: locates the first occurrence of the null-terminated string little
+in the string big, where not more than len characters are searched.
+
+`ft_atoi`: converts the initial portion of the string pointed to by nptr to
+int.
+
+`ft_calloc `: allocates memory for an array of nmemb elements of size bytes
+each and returns a pointer to the allocated memory. The memory is set to zero.
+If nmemb or size is 0, then calloc() returns a unique pointer value that can
+later be successfully passed to free(). If the multiplication of nmemb and
+size would result in integer overflow, then calloc() returns an error.
+
+`ft_strdup`: returns a pointer to a new string which is a duplicate of the
+string s. Memory for the new string is obtained with malloc(3), and can be
+freed with free(3).
+
+**Additional functions**
+
+`ft_substr`: Allocates memory (using malloc(3)) and returns a substring from
+the string ’s’. The substring starts at index ’start’ and has a maximum length
+of ’len’.
+
+`ft_strjoin`: Allocates memory (using malloc(3)) and returns a new string,
+which is the result of concatenating ’s1’ and ’s2’.
+
+`ft_strtrim`: Allocates memory (using malloc(3)) and returns a copy of ’s1’
+with characters from ’set’ removed from the beginning and the end.
+
+`ft_split`: Allocates memory (using malloc(3)) and returns an array of strings
+obtained by splitting ’s’ using the character ’c’ as a delimiter. The array
+must end with a NULL pointer.
+
+`ft_itoa`: Allocates memory (using malloc(3)) and returns a string representing
+the integer received as an argument. Negative numbers must be handled
+
+`ft_strmapi`: Applies the function f to each character of the string s, passing
+its index as the first argument and the character itself as the second. A new
+string is created (using malloc(3)) to store the results from the successive
+applications of f.
+
+`ft_striteri`: Applies the function ’f’ to each character of the string passed
+as argument, passing its index as the first argument. Each character is passed
+by address to ’f’ so it can be modified if necessary.
+
+`ft_putchar_fd`: Outputs the character ’c’ to the specified file descriptor.
+
+`ft_putstr_fd`: Outputs the string ’s’ to the specified file descriptor.
+
+`ft_putendl_fd`: Outputs the string ’s’ to the specified file descriptor
+followed by a new line.
+
+`ft_putnbr_fd`: Outputs the integer ’n’ to the specified file descriptor.
+
+**Linked list functions**
+
+The following struct was added to `libf.h`:
+
+ typedef struct s_list
+ {
+ void *content;
+ struct s_list *next;
+ } t_list;
+
+`ft_lstnew`: Allocates memory (using malloc(3)) and returns a new node. The
+’content’ member variable is initialised with the given parameter ’content’.
+The variable ’next’ is initialised to NULL.
+
+`ft_lstadd_front`: Adds the node ’new’ at the beginning of the list.
+
+`ft_lstsize`: Counts the number of nodes in the list.
+
+`ft_lstlast`: Returns the last node of the list.
+
+`ft_lstadd_back`: Adds the node ’new’ at the end of the list.
+
+`ft_lstdelone`: Takes a node as parameter and frees its content using the
+function ’del’. Free the node itself but does NOT free the next node.
+
+`ft_lstclear`: Deletes and frees the given node and all its successors, using
+the function ’del’ and free(3). Finally, set the pointer to the list to NULL.
+
+`ft_lstiter`: Iterates through the list ’lst’ and applies the function ’f’ to
+the content of each node.
+
+`ft_lstmap`: Iterates through the list ’lst’, applies the function ’f’ to each
+node’s content, and 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.
+
+License
+-------
+
+Libft Copyright (C) 2026 yctct
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+See the file COPYING.