Skip to content

My very first own library regrouping some usual functions in C

Notifications You must be signed in to change notification settings

JKAmadio/42sp_00_libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42SP_Libft

My very first own library regrouping some usual functions in C

Table of contents

Introduction

This project aims to code a C library regrouping usual functions that you’ll be allowed to use in all your other projects.

Technologies

Project is created with:

  • C

Functions

This project was divided into three parts and I added a new one for extra functions that I will formulate on my own as I advance in the 42SP course.

Part_1

In this part, I had to re-code some libc functions as defined in their man

Memory

Name Description
memset set memory areas to specific value
b_zero write zero-valued bytes
memcpy copy memory areas
memccpy copy memory area until character found
memmove copy memory areas, accept overlap
memchr scan memory for a character
memcmp compare memory areas

String

Name Description
strlen calculate len of string
strlcpy size-bounded string copy
strlcat size-bounded string concatenation
strchr scan string for a character
strrchr scan string for last occurance of a character
strnstr locate a substring
strncmp size-bounded comparation of two strings
atoi convert a string to integer

Classification

Name Description
isalpha classification routine: alphabetic character
isdigit classification routine: number character
isalnum classification routine: alphanumeric character
isascii classification routine: ASCII character
isprint classification routine: printable character
toupper convert letter to uppercase
tolower convert letter to lowercase

Allocation

Name Description
calloc allocate and free dynamic memory
strdup duplicate a string

Part_2

In this part, I had to code some functions that are either not included in the libc or included in a different form

String

Name Description
substr create new string with the substring of a string
strjoin concatenate two string into a new one
strtrim create new string with a set of characters removed from beginning and end
split split string into an array of strings
itoa convert integer to string
strmapi create new string from application of function to each character of a string

Output

Name Description
putchar_fd output a character to the given file descriptor
putstr_fd output a string to the given file descriptor
putendl_fd output a character to the given file descriptor, followed by a newline
putnbr_fd output an integer to the given file descriptor

Bonus

In this part, I had to code some important functions for the manipulation of linked lists.

Name Description
lstnew create new list
lstadd_front add new element to the beginning of list
lstsize count the elements of a list
lstlast finds the last element of list
lstadd_back add new element to the end of list
lstdelone delete a specific element of list
lstclear delete sequence of element of list
lstiter iterates the list and applies the function to the content of each element
lstmap apply function to content of all list's elements into new list

Extra

In construction...

Usage

Besides the function's files, this repository contains a libft.h file and a Makefile so that you can compile all the functions and use them in your project. To generate a libft.a file one of the commands bellow:

// Part 1 and Part 2 functions only
make

// all functions included
make bonus

and then compile your project with this file added to your compile command, such as:

gcc ~/path/to/your/project ~/path/to/your/libft.a

to keep your folder clean you may use one of the commands bellow:

// remove only the .o files
clean

// remove the .o files and the .a file
fclean

About

My very first own library regrouping some usual functions in C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published