Skip to content

rgrmra/libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


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

Project

This is the first project of the common core at 42 SĂŁo Paulo. The project wants that you recode some functions from C Library and other useful functions that you could use in your future projects.

Important

I have a new version of libft that contains the libft, get_next_line and ft_printf functions in the same project.
You could access it with the link bellow:

New libft version: libftx

Menu

  1. How to use it?
  2. Libft Documentation

How to use it?

Clone the repository to your project directory:

git clone https://github.com/rgrmra/libft.git libft

Mandatory:

Then use the command make inside the libft directory to build the compiled libft archive of the mandatory part of the project.

Bonus:

If you need the bonus part, use the command make bonus to include the bonus functions in the libft archive.

Remove:

To remove the objects compiled, use the command make clean.

Delete:

And, if you want to delete everything, use the command make fclean.

Declare:

To use the functions of the library you need to include it in your project and compile your project with the libft archive.

#include "libft.h"
gcc main.c -I ./libft ./libft/libft.a

Libft Documentation

NAME

  • libft.h - forty-two standard library

SYNOPSIS

#include "libft.h"

DESCRIPTION

The "libft.h" headers defines the folowing:

Type Definitions:

size_t

Unsigned integral type of the result of the sizeof operator. As described in <stddef.h>.


t_list

Linked list structure that provides the folowing filds:

source code

void            *content;
struct s_list    next;


Declarations:

The following are declared as functions and may also be defined as macros. Function prototypes must be provided for use with an ISO C compiler.

ft_atoi

Converts the initial portion of the string containing numeric characters to integer.

source code

int    ft_atoi(const char *nptr);

ft_bzero

Erase all bytes of the memory required with zero.

source code

void    ft_bzero(void *s, size_t n);

ft_calloc

Alloc a required space of memory and sets all bytes to zero.

source code

void    *ft_calloc(size_t nmemb, size_t size);

ft_isalnum

Checks for an alphanumeric character.

source code

int    ft_isalnum(int i);
ft_isalpha

Checks for an alphabetic character.

source code

int    ft_isalpha(int i);

ft_isascii

Checks whether character is a 7-bit US-ASCII character code.

source code

int    ft_isascii(int i);

ft_isdigit

Checks for a digit (0 through 9).

source code

int    ft_isdigit(int i);

ft_isprint

Checks for any printable character including space.

source code

int    ft_isprint(int i);

ft_itoa

Converts a integer to string.

source code

char    *ft_itoa(int i);

ft_lstadd_back (bonus)

Append a new node to the end of a list.

source code

void    ft_lstadd_back(t_list **lst, t_list *new);

ft_lstadd_front (bonus)

Append a new node to the begin of a list.

source code

void    ft_lstadd_front(t_list **lst, t_list *new);

ft_lstclear (bonus)

Erases all content and nodes of a list.

source code

void    ft_lstclear(t_list **lst, void (*del)(void *));

ft_lstdelone (bonus)

Deletes one node of a list.

source code

void    ft_lstdelone(t_list *lst, void (*del)(void *));

ft_lstiter (bonus)

Applies a function to each content of a node of a list.

source code

void    ft_lstiter(t_list *lst, void (*f)(void *));

ft_lstlast (bonus)

Gets the last node of a list.

source code

t_list    ft_lstlast(t_list *lst);

ft_lstmap (bonus)

Returns a new list applying a required function to each node of the list.

source code

t_list    ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));

ft_lstnew (bonus)

Creates a new node.

source code

t_list    *ft_lstnew(void *content);

ft_lstsize (bonus)

Gets the size of a list.

source code

int    ft_lstsize(t_list *lst);

ft_memchr

Finds the first required byte in an area pointed in the memory.

source code

void    *ft_memchr(const void *s, int c, size_t n);

ft_memcmp

Compares the amount of bytes between two areas pointed in the memory.

source code

int    ft_memcmp(const void *s1, const void *s2, size_t n);

ft_memcpy

Copies the required amount of bytes from an area to another area pointed in the memory.

source code

void    *ft_memcpy(void *dest, const void *src, size_t n);

ft_memmove

Moves an requried amount of bytes from an area to another area pointed in the memory.

source code

void    *ft_memmove(void *dest, const void *src, size_t	n);

ft_memset

Sets all bytes required in the memory area pointed with the byte informed.

source code

void    *ft_memset(void *s, int c, size_t n);

ft_putchar_fd

Prints a char in the required filedescriptor.

source code

void    ft_putchar_fd(char c, int fd);

ft_putendl_fd

Prints a string followed by a new line in the required filedescriptor.

source code

void    ft_putendl_fd(char *s, int fd);

ft_putnbr_fd

Prints a integer number in the required filedescriptor.

source code

void    ft_putnbr_fd(int n, int fd);

ft_putstr_fd

Prints a string in the required filedescriptor.

source code

void    ft_putstr_fd(char *s, int fd);

ft_split

Splits a constant string into an allocated array of strings containg the words splited by the required separator.

source code

char    **ft_split(const char *s, char c);

ft_strchr

Finds the first required character in a constant string.

source code

char    *ft_strchr(const char *s, int c);

ft_strdup

Duplicates a required constant string.

source code

char    *ft_strdup(const char *s);

ft_striteri

Iterates a function to each character of a string.

source code

void    ft_striteri(char *s, void (*f)(unsigned int, char *));

ft_strjoin

Concatenates a new string containg the two strings informed.

source code

char    *ft_strjoin(const char *s1, const char *s2);

ft_strlcat

Concatemates a string to another string informed.

source code

size_t    ft_strlcat(char *dest, char *src, size_t size);

ft_strlcpy

Copies the content of a string to another string informed.

source code

size_t    ft_strlcpy(char *dest, char *src, size_t size);

ft_strlen

Gets the size of a constant string.

source code

size_t    ft_strlen(const char *s);

ft_strmapi

Duplicates a new string and applies a function to each character of the string.

source code

char    *ft_strmapi(const char *s, char (*f)(unsigned int, char));

ft_strncmp

Compares two strings.

source code

int    ft_strncmp(const char *s1, const char *s2, size_t n);

ft_strrchr

Finds the last required character in a constant string.

source code

char    *ft_strrchr(const char *s, int c);

ft_strtrim

Removes the amount of required characters in the begin and end of the string.

source code

char    *ft_strtrim(const char *s1, const char *set);

ft_substr

Generates a sub new string from a required string.

source code

char    *ft_substr(const char *s, unsigned int start, size_t len);

ft_tolower

Changes all uppercase characters to lowecase.

source code

int    ft_tolower(int i);

ft_toupper

Changes all lowecase characters to uppercase.

source code

int    ft_toupper(int i);

  • Inclusion of "libft.h" header may also make visible all symbols from <stddef.h> and <stdlib.h>.

APPLICATION USAGE

  • None

FUTURE DIRECTIONS

  • None