Skip to content

This project is about coding a C library. It will contain a lot of general purpose functions your programs will rely upon.

Notifications You must be signed in to change notification settings

mouaammou/libft-42

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Libft - 42 Project

Libft - 42 Project

Table of Contents

Introduction

Welcome to Libft, the first project of the 42 curriculum. The goal of this project is to create a C library that will mimic some of the standard C library functions and additional utility functions that will be used throughout the 42 projects.

Project Overview

Libft is a custom implementation of several standard C library functions, including string manipulation, memory handling, and more. This project serves as a foundation for future C projects within the 42 curriculum. By writing these functions from scratch, students develop a deep understanding of how basic functions work under the hood.

Features

  • Custom implementation of several essential C standard library functions.
  • Includes additional utility functions to facilitate development in future 42 projects.
  • Adheres to strict C coding standards imposed by the 42 network (norminette compliant).

Functions Implemented

Libft includes the following categories of functions:

Part 1 - Libc Functions

  • ft_memset - Fill memory with a constant byte
  • ft_bzero - Zero out a byte string
  • ft_memcpy - Copy memory area
  • ft_memmove - Move memory area
  • ft_memchr - Scan memory for a character
  • ft_memcmp - Compare memory areas
  • ft_strlen - Calculate the length of a string
  • ft_strdup - Duplicate a string
  • ft_strcpy - Copy a string
  • ft_strncpy - Copy a string up to n characters
  • ft_strcat - Concatenate two strings
  • ft_strncat - Concatenate two strings, up to n characters
  • ft_strchr - Locate character in string
  • ft_strrchr - Locate character in string from the end
  • ...and many more!

Part 2 - Additional Functions

  • ft_substr - Extract a substring from a string
  • ft_strjoin - Concatenate two strings into a new one
  • ft_strtrim - Trim leading and trailing characters from a string
  • ft_split - Split a string into an array based on a delimiter
  • ft_itoa - Convert an integer to a string
  • ft_putchar_fd - Output a character to a file descriptor
  • ft_putstr_fd - Output a string to a file descriptor
  • ft_putendl_fd - Output a string to a file descriptor, followed by a newline
  • ft_putnbr_fd - Output an integer to a file descriptor

Bonus Part - Linked List Functions

  • ft_lstnew - Create a new list node
  • ft_lstadd_front - Add a node to the beginning of the list
  • ft_lstsize - Count the number of nodes in a list
  • ft_lstlast - Return the last node of the list
  • ft_lstadd_back - Add a node to the end of the list
  • ft_lstdelone - Delete a node and free its content
  • ft_lstclear - Clear the entire list
  • ft_lstiter - Apply a function to each node of the list
  • ft_lstmap - Apply a function to each node and return a new list

Installation

To use the library in your projects:

  1. Clone the repository:

    git clone https://github.com/mouaammou/libft-42.git
  2. Navigate into the project directory:

    cd libft
  3. Compile the library:

    make
  4. The compiled library will be available as libft.a.

Usage

To use libft in your project, you need to include it during compilation:

  1. Add the header file:

    #include "libft.h"
  2. Compile your project with libft.a:

    gcc -Wall -Wextra -Werror -o your_program your_program.c -L. -lft

Example

#include "libft.h"

int main(void)
{
    char str[] = "Hello, World!";
    ft_strrev(str);
    printf("%s\n", str); // Output: !dlroW ,olleH
    return 0;
}

Testing

You can run tests with external testers or write your own to verify your implementation. Some popular testers include:

About

This project is about coding a C library. It will contain a lot of general purpose functions your programs will rely upon.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published