Giter Site home page Giter Site logo

unilui / 42_libft Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 221 KB

My very first own library. This project is about coding a C library. It contains a lot of general purpose functions that my programs rely upon.

Makefile 1.67% C 98.33%
data-structures-and-algorithms debugging library memory-management gdb header-files makefiles static-variables valgrind variadic-functions

42_libft's Introduction

42_Libft

Summary:

Introduction:

The aim of this project is to code a C library regrouping usual functions.

  • First part: re-code a set of the libc functions, as defined in their man, with the same prototype and behaviors as the originals.
  • Second part: code a set of functions that are either not included in the libc, or included in a different form.
  • Extras: add any function to the 42_libft as I see fit.

Subjects_studied:

⦿ Dinamic memory allocation.

⦿ Memory management.

⦿ Data structures.

⦿ Data types.

⦿ Variadic functions.

⦿ Static variables.

⦿ Header and Makefile.

⦿ Debugging with gdb and valgrind.

⦿ Flow program organization.


Part_1:

ctype.h

Function Description
ft_isalpha Checks for an alphabetic character.
ft_isdigit Checks for a digit (0 through 9).
ft_isalnum Checks for an alphanumeric character; it is equivalent to (isalpha(c)
ft_isascii Checks whether c is a 7-bit unsigned char value that fits into the ASCII character set.
ft_isprint Checks for any printable character including space.
ft_toupper Convert lowercase letters to uppercase
ft_tolower Convert uppercase letters to lowercase.

string.h

Function Description
ft_memset Fills the first n bytes of the memory area pointed to by s with the constant byte c
ft_bzero Erases the data in the n bytes of the memory starting at the location pointed to by s, by writing zeros (bytes containing '\0') to that area.
ft_memcpy Copies n bytes from memory area src to memory area dest. The memory areas must not overlap. Use memmove(3) if the memory areas do overlap.
ft_memmove Copies n bytes from memory area src to memory area dest. The two strings may overlap; the copy is always done in a non-destructive manner.
ft_memchr Scans the initial n bytes of the memory area pointed to by s for the first instance of c.
ft_memcmp Compares the first n bytes (each interpreted as unsigned char) of the memory areas s1 and s2.
ft_strlen Computes and returns the length of the string s.
ft_strlcpy Copies up to size - 1 characters from the NUL-terminated string src to dst, NUL-terminating the result.
ft_strlcat Appends the NUL-terminated string src to the end of dst. It will append at most size - strlen(dst) - 1 bytes, NUL-terminating the result.
ft_strchr Returns a pointer to the first occurrence of the character c in the string s.
ft_chrpst Returns the index of the first occurrence of the character c in the string s.
ft_strrchr Returns a pointer to the last occurrence of the character c in the string s.
ft_strnstr Locates the first occurrence of the null-terminated string little in the string big, where not more than len characters are searched.
ft_strncmp Lexicographically compares the null-terminated strings s1 and s2. Returns an integer greater than, equal to, or less than 0, according as the string s1 is greater than, equal to, or less than the string s2. Compares not more than n characters. The comparison is done using unsigned characters, so that '\200' is greater than '\0'.
ft_strcmp Lexicographically compares the null-terminated strings s1 and s2. Returns an integer greater than, equal to, or less than 0, according as the string s1 is greater than, equal to, or less than the string s2. The comparison is done using unsigned characters, so that '\200' is greater than '\0'.
ft_strdup Returns a pointer to a new string which is a duplicate of the string s.

stdlib.h

Function Description
ft_atoi Converts the initial portion of the string pointed to by str to int representation and returns the int.
ft_calloc Allocates memory for an array of nmemb elements of size bytes each and returns a pointer to the allocated memory. The memory is set to zero.

Part_2:

String's functions:

Function Description
ft_printf Formats and prints its arguments, after the first, under control of the format. The format is a character string which contains two types of objects: plain characters, which are simply copied to standard output and character escape sequences which are converted and copied to the standard output, each of which causes printing of the next successive argument.
ft_substr Allocates and returns a substring from the string ’s’. The substring begins at index ’start’ and is of maximum size ’len’.
ft_strjoin Allocates and returns a new string, which is the result of the concatenation of ’s1’ and ’s2’.
ft_strtrim Allocates and returns a copy of ’s1’ with the characters specified in ’set’ removed from the beginning and the end of the string.
ft_split Allocates and returns an array of strings obtained by splitting ’str’ using the character ’sep’ as a delimiter.
ft_strmapi Applies the function ’f’ to each character of the string ’s’ to create a new string resulting from successive applications of ’f’.
ft_striteri Applies the function ’f’ on each character of the string passed as argument, passing its index as first argument. Each character is passed by address to ’f’ to be modified if necessary.

String to int:

Function Description
ft_itoa Allocates and returns a string representing the integer received as an argument. Negative numbers must be handled.

File-descriptor's functions:

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

Extras:

Function Description
get_next_line Returns a line read from a file descriptor.
ft_putchar Outputs the character c to the standard output.
ft_putstr Outputs a string to the standard output.
ft_putnbr Outputs the integer n to the standard output.
ft_sort_int_tab Sorts an array of integers by ascending order.
ft_swap Swaps the value of two integers whose addresses are entered as parameters.

Makefile:

Command Usage
make creates .o files for each function as well as the master library file, "libft.a".
make clean removes the .o files used to create the library.
make fclean removes the .o & .a files used to create the library.
make re removes all .o & .a files then remakes them.

Tests:

42_libft's People

Contributors

unilui 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.