Skip to content
/ Libft Public

This project aims to objectively a repeat functions from C.

License

Notifications You must be signed in to change notification settings

gapima/Libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

42cursus

libft

libft

Inside this repository, you can see all the code that has been created for the libft project, including the mandatory parts 1 and 2 as well as the bonus functions. These functions must be compiled into a library named libft.a using a Makefile.


Final score

libft

Part 1

Re-code some of the Standard C Library. The functions must behavior as the originals.

Function Description
isalpha Check if it's an alphabetic character
isdigit Check if it's digit
isalnum Check if it's an alphanumeric character
isascii Check if it's in the ASCII range
isprint Check if it's a printable character
strlen Calculate the lenght of a string
memset Fill the bytes of a block of memory with a constant value
bzero Fill the bytes of a block of memory with zero
memcpy Copy a memory block
memmove Copy a memory block
strlcpy Copy a string
strlcat Concatenate two strings
toupper Conver a character to uppercase
tolower Convert a character to lowercase
strchr Search for the first appearence of a character in a string
strrchr Search for the last appearence of a character in a string
strncmp Compare two strings
memchr Search for a character in a block of memory
memcmp Compare two blocks of memory
strnstr Search for a substring in a string
atoi Convert a string to an integer
calloc Allocate memory and fill its bytes to zero
strdup Duplicate a string

Part 2

Code some helpful functions that are not in the Standard C Library.

Function Description
substr Return a substring from a string
strjoin Concatenate two strings
strtrim Trim the beggining and the end of a string
split Split a string
itoa Convert a number into a string
strmapi Apply a function in every character of a string
striteri Apply a function in every character of a string
putchar_fd Write a character to a file
putstr_fd Write a string to a file
putendl_fd Write a string to a file, followed by a new line
putnbr_fd Write a number to a file

Bonus

Code some functions to manipulate lists.

Function Description
lstnew Create a new node
lstadd_front Add a node in front of a list
lstsize Count the nodes in a list
lstlast Return the last node of a list
lstadd_back Add a node in the end of a list
lstdelone Free the content os a node in a list
lstclear Delete and free a list
lstiter Apply a function to every node of a list
lstmap Apply a function to every node of a list

Instructions to use

Clone this repository in you local computer using a terminal:

After cloning the lib in your local reposiory you run some commands you can find in Makefile:

  • $> make all: or just make compiles only the mandatory parts
  • $> make bonus: compiles the bonus part
  • $> make clean: deletes the object files created during compilation
  • $> make fclean: executes the clean command and also deletes the libft.a
  • $> make re: executes the fclean command followed by the all command
  • $> make rebonus: executes the fclean command followed by the bonus command
To use libft in your projects you need to include its header:
  • #include "libft.h"

To compile your projects that use libft you need to use the flags:

  • $> ... -lft -L [path/to/libft.a] -I [path/to/libft.h]

About

This project aims to objectively a repeat functions from C.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published