Giter Site home page Giter Site logo

42_libft's Introduction

LIBFT

Your very first own library

GitHub code size in bytes Code language count GitHub top language GitHub last commit


πŸ—£ About

This project is about coding a C library. It will contain a lot of general purpose functions your programs will rely upon. It is your very first project as a student at 42. You will need to recode a few functions of the C standard library as well as some other utility functions that you will use during your whole cursus.

πŸ›  Usage

Requirements

The library is written in C language and thus needs the gcc compiler and some standard C libraries to run.

Instructions

1. Compiling the library

To compile the library, run:

$ cd path/to/libft && make

2. Using it in your code

To use the library functions in your code, simply include its header:

#include "libft.h"

3. Link your program with libft.a

LIBFT_DIR = path/to/libft
LIBFT = $(LIBFT_DIR)/libft.a

$(NAME): $(LIBFT)
	gcc $(LIBFT) $(MY_SRCS)...

$(LIBFT):
	make -C $(LIBFT_DIR)

πŸ’¬ Description

string

Function Description
ft_strlen Computes the length of the string ’s’. (not protected)
ft_strlcpy Copies ’src’ to ’dst’
ft_strlcat Concatenates ’src’ to ’dst’
ft_strchr Locates the first occurrence of the character ’c’ in the string ’s’
ft_strrchr Locates the last occurrence of the character ’c’ in the string ’s’
ft_strcmp Compares the two strings ’s1’ and ’s2’
ft_strncmp Compares ’n’ characters of the two strings ’s1’ and ’s2’
ft_strncpy Copies at most ’len’ characters from ’src’ to ’dst’
ft_strnstr Locates the first occurrence of ’needle’ in ’haystack’, within ’len’ characters
ft_strdup Allocates a copy of ’s1’
ft_substr Allocates a sub-string from the string ’s’
ft_strjoin Allocates new string, which is the result of the concatenation of ’s1’ and ’s2’
ft_strtrim Allocates a copy of ’s1’ with all characters specified in ’set’ removed from the beginning and the end of the string.
ft_split Splits ’s’ using the character ’c’ as a delimiter
ft_strmapi Applies the function ’f’ to each character of ’s’, returning new string
ft_striteri Applies the function ’f’ on each character of ’s’

memory

Function Description
ft_calloc Allocates space for ’count’ elements that are ’size’ bytes of memory, filled with zeroed bytes.
ft_memset Writes ’len’ bytes of value ’c’ to the array ’b’
ft_bzero Writes ’n’ zeroed bytes to the string ’s’
ft_memcpy Copies ’n’ bytes from memory area ’src’ to memory area ’dst’
ft_memmove Copies ’len’ bytes from string ’src’ to string ’dst’ (non-destructive manner)
ft_memchr Searches for the first occurence of ’c’ in ’s’ within ’n’ bytes
ft_memcmp Compares byte string ’s1’ against byte string ’s2’

print

Function Description
ft_putchar_fd Outputs the character ’c’ to the given file descriptor ’fd’
ft_putstr_fd Outputs the string ’s’ to the given file descriptor ’fd’
ft_putendl_fd Outputs the string ’s’ to the given file descriptor ’fd’ followed by a newline
ft_putnbr_fd Outputs the integer ’n’ to the given file descriptor ’fd’

convert

Function Description
ft_toupper Converts a lower-case letter to the corresponding upper-case letter
ft_tolower Converts a upper-case letter to the corresponding lower-case letter
ft_atoi Converts the initial portion of ’str’ to int representation
ft_itoa Converts the integer ’n’ to string representation

check

Function Description
ft_isalpha Checks character for an alphabetic character
ft_isdigit Checks character for a digit
ft_isalnum Checks character for an alhabetic character or digit
ft_isprint Checks character for a printable character
ft_isascii Checks character for an ascii character

linked list (bonus)

Function Description
ft_lstnew Allocates and returns a new node
ft_lstadd_front Adds the node ’new’ at the beginning of the list
ft_lstsize Counts the number of nodes in a 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 Frees the memory of the node’s content using the function ’del’ given as a parameter and free the node
ft_lstclear Deletes and frees the given node and every successor of that node, using the function ’del’ and free
ft_lstiter Iterates the list ’lst’ and applies the function ’f’ on the content of each node
ft_lstmap Creates a new list resulting of the successive applications of the function ’f’

42_libft's People

Contributors

aaron-22766 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.