Skip to content

Latest commit

Β 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

libft


C

42 42 Lisboa GitHub GitHub last commit

A comprehensive C library containing reimplementations of standard C library functions, plus additional utility functions for string manipulation, memory management, linked lists, and formatted output.

πŸ“‹ Table of Contents

πŸ“š About

libft is a custom C library developed as part of the 42 School curriculum. It provides essential functions for C programming, including:

  • Standard C library function reimplementations
  • Additional utility functions for string and memory operations
  • Linked list manipulation functions
  • Custom printf implementation with file descriptor support
  • get_next_line function for reading files line by line

πŸš€ Features

Part I - Standard C Library Functions

Part II - Additional String Functions

Part III - Linked Lists

typedef struct s_list
{
    void            *content;
    struct s_list   *next;
} t_list;

Printf Implementation

Custom ft_printf function with support for:

  • Format specifiers: %c, %s, %d, %i, %u, %x, %X, %p, %%
  • Flags: -, 0, #, , +
  • Width and precision: *, .
  • File descriptor version: ft_printf_fd

Get Next Line

get_next_line function for reading files line by line with configurable buffer size.

πŸ› οΈ Installation

Prerequisites

  • GCC or any C compiler
  • Make

Build

# Clone the repository
git clone https://github.com/yourusername/libft.git
cd libft

# Compile the library
make

# Clean object files
make clean

# Clean everything
make fclean

# Recompile
make re

πŸ“– Usage

Include in your project

#include "libft.h"

Link with your program

gcc -Wall -Wextra -Werror your_file.c -L. -lft

Example usage

#include "libft.h"

int main(void)
{
    // String functions
    char *str = ft_strdup("Hello, World!");
    char **split = ft_split(str, ' ');

    // Linked list
    t_list *list = ft_lstnew("First");
    ft_lstadd_back(&list, ft_lstnew("Second"));

    // Printf
    ft_printf("Number: %d, String: %s\n", 42, "libft");

    // Memory cleanup
    free(str);
    // ... free split array and list

    return (0);
}

πŸ“ Project Structure

libft/
β”œβ”€β”€ Makefile                 # Build configuration
β”œβ”€β”€ libft.h                 # Main header file
β”œβ”€β”€ ft_printf.h             # Printf header file
β”œβ”€β”€ get_next_line.h         # Get next line header file
β”œβ”€β”€ README.md               # This file
β”œβ”€β”€ .gitignore             # Git ignore rules
β”œβ”€β”€ ft_*.c                 # Function implementations
└── obj/                   # Object files (created during build)

πŸ§ͺ Testing

The library has been thoroughly tested with:

  • Custom test suites
  • 42 School testers
  • Memory leak detection with Valgrind
  • Edge cases and error handling

⚑ Performance

  • Optimized algorithms for memory operations
  • Efficient string manipulation
  • Minimal memory footprint
  • No unnecessary function calls

πŸ“Š Function Categories

Category Functions Description
Character Tests 5 functions Check character properties
String Operations 15+ functions String manipulation and analysis
Memory Management 8 functions Memory allocation and manipulation
Linked Lists 9 functions Dynamic data structure operations
File I/O 6 functions File descriptor operations
Printf 15+ functions Formatted output implementation
Utilities 10+ functions Helper and conversion functions

πŸ”§ Compilation Flags

The library is compiled with strict flags to ensure code quality:

-Wall -Wextra -Werror

🚫 Forbidden Functions

This implementation doesn't use any external libraries except for:

  • malloc, free (memory management)
  • write (system call)
  • Standard library headers for type definitions

πŸ’‘ Key Features

  • Memory Safe: All functions handle edge cases and prevent buffer overflows
  • Norm Compliant: Follows 42 School coding standards
  • Well Documented: Each function includes comprehensive documentation
  • Modular Design: Functions can be used independently
  • Performance Optimized: Efficient algorithms and minimal overhead

🀝 Contributing

This is an educational project for 42 School. While not accepting external contributions, feel free to:

  • Report bugs
  • Suggest improvements
  • Use as a reference for your own implementation

πŸ“œ License

This project is part of the 42 School curriculum and follows their academic guidelines.

πŸ‘¨β€πŸ’» Author

joamiran - 42 Lisboa Student


This library represents a comprehensive foundation for C programming, providing essential tools for memory management, string manipulation, and formatted output while maintaining high code quality standards.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages