Skip to content

Bruno0798/42_libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 

Repository files navigation

libft

ℹ️ A C static library with recoded standard functions

100/100

GitHub code size in bytes Code language count 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.
42 makes us do this just so we can have a deeper understanding of data structures and basic algorithms. At 42, certain standard libraries are prohibited in our projects, compelling us to continually expand our custom library with self-built functions as we advance in the program.

⚠️ Warning: Don't copy/paste code you don't understand: it's bad for you, and for the school.

Functions

Functions from <ctype.h>

Functions from <string.h>

Functions from <stdlib.h>

Non-standard functions

  • ft_substr - extract substring from string.
  • ft_strjoin - concatenate two strings into a new string (with malloc).
  • ft_strtrim - trim beginning and end of string with the specified characters.
  • ft_split - split string, with specified character as delimiter, into an array of strings.
  • ft_itoa - convert integer to ASCII string.
  • ft_strmapi - create new string from modifying string with specified function.
  • ft_striteri - applies a provided function to each character in a string.
  • ft_putchar_fd - output a character to given file.
  • ft_putstr_fd - output string to given file.
  • ft_putendl - output string to stdout with newline.
  • ft_putnbr_fd - output integer to given file.

Note

  • Most of the the files and function names are namespaced with an ft in front. It stands for Forty Two

How does libft work?

It aims to create a library called libft.a from the source files.

To create this library, clone the project:

git clone git@github.com:Bruno0798/42_libft.git

Enter the repository:

cd libft

Run Make (to run the Makefile that will compile the source code and create the library):

make

You should see a libft.a file and some object files (.o).

Now to clean up (removing the .o files), call make clean:

make clean

Now you just have to add this header at your .c files and use the Libft functions:

#include "libft.h"

If you try to compile your .c files with clang using clang example.c you will get an undefined symbol error for Libft functions.

You have to tell the file where your library resides:

clang example.c libft.a

That's it. Now run it using ./a.out

MAKEFILE RULES

make - Compile libft mandatory files.

make clean - Delete all .o (object files) files.

make fclean - Delete all .o (object file) and .a (executable) files.

make re - Use rules fclean + all.

NORMINETTE

At 42 School, aligning to the 42 Norms, the school's coding standard, is a fundamental expectation for all projects.

About

A C static library with recoded standard functions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors