P-Claus / libft

The files that are needed for the libft project at Campus 19.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Libft (Static Library in C)

libft header

Campus 19 Profile status GitHub code size in bytes Code language count GitHub top language GitHub last commit

Overview

In this introductory project, I am excited to create my own personal static library in the C programming language. This project marks the beginning of my journey at campus19 and provides an opportunity to dive into C programming concepts while building a fundamental software component.

The project is called libft and is an exercise that requires you to use many things learnt during the piscine. Most of the functions in this project were written during the piscine (in one form or another).

Result

libft result

After libft project

Once I finished the libft project, I started rewriting some of the functions and makefile to use the library in other projects. The current state of the project is not what I submitted to moulinette. All updates after 18 January 2024 might not pass the moulinette because of changes in some functions and rules in the makefile.

Functions

Functions from <string.h> library

  • ft_strlen: calculates the length of a string
  • ft_memset: writes a certain amount of bytes (len) of value c to string b
  • ft_memcpy: copies certain amount of bytes (n) from src ro dst
  • ft_memmove: copies a certain amount of bytes (len) from src to dst (there may be overlap)
  • ft_strlcpy: copies up to dstsize -1 from src to dst and null-terminates the new string (returns the string it tried to create so length of src)
  • ft_strlcat: concatenates src to the end of dst and makes sure the new string is not longer than size to prevent buffer overflow
  • ft_strchr: searches if c is in the string and returns a pointer to the first c
  • ft_strrchr: searches if c is in a string and returns a pointer to the last c
  • ft_strncmp: compares a maximum of n characters of s1 and s2 and returns the difference in ASCII value
  • ft_memchr: searches a memory block forc(converted to unsigned char) and returns a pointer to the byte
  • ft_memcmp: compares s1 and s2 up to n characters and returns the difference in ASCII value
  • ft_strnstr: this looks for a substring in a string and returns a pointer to the substring
  • ft_strdup: duplicates a string and returns a pointer to the new string

Functions from <strings.h> library

  • ft_bzero: writes n-bytes of 0 to a string s

Functions from <ctype.h> library

Functions from <stdlib.h> library

  • ft_atoi: converts string to integer
  • ft_calloc: allocates memory for a number of elements and sets that memory to 0

Additional functions

  • ft_substr: creates and returns a substring from a string
  • ft_strjoin: creates a new string by concatenating s1 and s2
  • ft_strtrim: removes characters specified in set from start and end in s1
  • ft_split: creates a new array of strings from an existing string using a separator
  • ft_itoa: converts an int to a string
  • ft_strmapi: creates a new string by applying a function to each character in an existing string
  • ft_striteri: applies a function to each character in a string and modifying it if necessary
  • ft_putchar_fd: outputs c to the file descriptor
  • ft_putstr_fd: outputs a string to the file descriptor
  • ft_putendl_fd: outputs a string to the file descriptor, followed by a newline
  • ft_putnbr_fd: outputs an int n to the file descriptor

Functions for linked lists

  • ft_lstnew: creates a new node in a linked list
  • ft_lstadd_front: adds a new node to the front of an existing linked list
  • ft_lstsize: returns the size of a linked list
  • ft_lstlast: returns the last node in a linked list
  • ft_lstadd_back: adds a node to the back of a linked list
  • ft_lstdelone: takes del function as parameter and frees the memory of a node's content and frees the node
  • ft_lstclear: clears a list by deleting and freeing every node in a linked list
  • ft_lstiter: iterates the linked list and applies the function f on the content of each node
  • ft_lstmap: creates a new linked list by applying the function f to the content of each node

About

The files that are needed for the libft project at Campus 19.


Languages

Language:C 98.5%Language:Makefile 1.5%