MaazBinNaseer / 42-LibFt-

Creating our own library folder from start

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

42-LibFt-

image image

📚 Creating our own library folder from start

❗ MANDATORY PART

S.No Function Description
1. isAlnum Checks whether the string has alphabets and numbers; if true returns 1
2. isAlpha Read the string: If there is alphabets- it should return the value of 1
3. isAscii Returns 1 if c is an ASCII character; otherwise, zero
4. isDigit Function isdigit() takes a single argument in the form of an integer and returns the value of type int
5. isPrint Returns 1 if the characet is printable
6. Bzero Sets everything to zero
7. Calloc Allocates memory and sets the memory that has been allocated to zero
8. Memcmp It checks for strings and returns the difference, it also checks for null space
9. Memcpy Copies all the data from the source to the destination
10. Memset Fills the block of memory or the string to a particular value
11. Memmove Moves everythin from the source to the destination, handles overlap which memcpy cannot
12. Memchr It will look for a character inside the string and returns character from that position of the character
13. Strchr Looks for a specific character inside the string and returns the string from that character position
14. Strrchr Looks for a specific character but the last character inside that string and returns that character/string
15. Strlen Returns the string length
16. Strncmp Compares not more than n characters. If found a difference within the n value, it will return the difference
17. Strrstr Returns the character inside the string where it last occured
18. Strnstr Looks for a string inside a source string and returns the string if found inside the source string
19. Split Splits the strings into different positions
20. Strdup duplisubstrthe string from the source to the destination
21. Strjoin Joins both the source and destination string into another string (malloc)
22. Strlcat Returns both the source and destination string concatination, but with restrictions
23. Strlcpy Basically copies the source string to destination string but with a limitation of "how much to copy"
24. Strtrim Removes the string from the start and end, specified by the user
25. Substr Subtracts the string given the parameters by the user. “We are going home” we specify where the index starting position is and we also assing n value to return that much of the string. Lets say start = 3 and n = 7, the function will return “are g” to be stored into another string(malloc)
26. Atoi Converts string to integers value
27. Itoa Converts integers to string literal
28. ToUpper Converts the character to uppercase
29. ToLower Converts the character to lowercase
30. Strmapi Change the character using the (f) function
31. Striteri Changing the character through (f) function
32. Putchar_fd Outputs the character c to the given file descriptor
33. Putstr_fd Outputs the string to the given file descriptor
34. Putendl_fd Outputs a string to the file descriptor but ends with a newline
35. Putnbr_fd Outputs the integer n to given file descriptor

✔️ BONUS PART

S.No Function Description
36. Lstnew Allocates a new node and variable next is initialized to Null
37. Lstadd_front Adds the node new at the beginning of the list
38. Lstsize Counts the number of nodes in a list
39. lstlast Returns the last node of the list
40. lstadd_back Adds the node new at the end of the list
41. lstdelone Free the node content using the delete and the next must not be freed
42. lstclear Deletes and frees the given node and every successor of that node, using the del and free
43. lstiter Iterates the list list and applies the function f on the content of each node.
44. lstmap Creates a new list and applies the function of the f on the content of each node. The del function is used to delete the content of a node if needed.

✏️ THINGS TO READ ABOUT

📄 MAKEFILE

//Generating an .O file 
clang/gcc -c file.c 
//Compressing all files together 
clang/gcc file1.o fil2.o -o file -l m 

Understanding wildcards & phony

A single file name can specify many files using wildcard characters. The wildcard characters in make are ‘*’, ‘?’ and ‘[…]’, the same as in the Bourne shell. For example, *.c specifies a list of all the files (in the working directory) whose names end in ‘.c’.

The character ‘~’ at the beginning of a file name also has special significance. If alone, or followed by a slash, it represents your home directory. For example /bin expands to /home/you/bin. If the ‘’ is followed by a word, the string represents the home directory of the user named by that word. For example ~john/bin expands to /home/john/bin. On systems which don’t have a home directory for each user (such as MS-DOS or MS-Windows), this functionality can be simulated by setting the environment variable HOME

Wildcard examples

To set objectsto the expansion, instead use:

`**objects := $(wildcard *.o)

Some Wildcard Syntax:
$@ : The filename representing the target.
$^: the filenames of all the prerequisites, separated by spaces. 
This list has duplicate filenames removed since for most uses, such as compiling, copying, etc., duplicates are not wanted.

%.o:%.c -----> $(CC) $*(CFLAGS) -c -o ($@):targets %.o ($^):targets %.c

Phony

A phony target is one that is not really the name of a file; rather it is just a name for a recipe to be executed when you make an explicit request. There are two reasons to use a phony target: to avoid a conflict with a file of the same name, and to improve performance

Writing Rules in MakeFiles

c

Create the archive. The specified archive is always created if it did not exist, when you request an update. But a warning is issued unless you specify in advance that you expect to create it, by using this modifier.

r

Insert the files member... into archive (with replacement). This operation differs from q in that any previously existing members are deleted if their names match those being added.

s

Write an object-file index into the archive, or update an existing one, even if no other change is made to the archive. You may use this modifier flag either with any operation, or alone. Running "ar s" on an archive is equivalent to running ranlib on it. Therefore, rcscan be seen to mean `replace, create, sort

CFILES= $(wildcard ./*.c) //Gets all the .c files in the directory and stores it into the variable called CFILES //
$(NAME): $(OBJECTS)
	ar -rcs $(NAME) $(OBJECTS)

📹 Markdown tutorial

MARKDOWN TUTORIAL

About

Creating our own library folder from start


Languages

Language:C 97.3%Language:Makefile 2.7%