starting to create comments and an implemantation of a circular linked list

This commit is contained in:
Willem Haffmans 2024-11-03 10:49:45 +00:00
parent d121dae56f
commit 18e88699a6
10 changed files with 70 additions and 2 deletions

View File

@ -20,6 +20,14 @@ typedef struct s_list
struct s_list *next;
} t_list;
typedef struct s_clist
{
void *content;
struct s_clist *next;
struct s_clist *prev;
} t_clist;
int ft_isalpha(int c);
int ft_isdigit(int c);
int ft_isalnum(int c);

View File

@ -12,6 +12,14 @@
#include "libft.h"
/**
* @brief ft_isalnum() checks if a character is a digit or an
* alphabetical character.
*
* @param c contains an integer of the character to be tested.
* @return int returns c if the int codes for an digit or an alphabetical
* character.
*/
int ft_isalnum(int c)
{
return (ft_isdigit(c) || ft_isalpha(c));

View File

@ -12,6 +12,12 @@
#include "libft.h"
/**
* @brief ft_isalpha() checks if a character is an alphabetical character.
*
* @param c contains an integer of the character to be tested.
* @return int returns c if the int codes for an alphabetical character.
*/
int ft_isalpha(int c)
{
return (('A' <= c && 'Z' >= c) || ('a' <= c && 'z' >= c));

View File

@ -12,6 +12,13 @@
#include "libft.h"
/**
* @brief ft_isalnum() checks if a character is an ascii character
*
* @param c contains an integer of the character to be tested.
* @return int returns c if the int codes for an digit or an ascii
* character.
*/
int ft_isascii(int c)
{
return (0 <= c && 127 >= c);

View File

@ -12,6 +12,12 @@
#include "libft.h"
/**
* @brief ft_isdigit() checks if a character is a digit.
*
* @param c contains an integer of the character to be tested.
* @return int returns c if the int codes for an digit.
*/
int ft_isdigit(int c)
{
return ('0' <= c && '9' >= c);

View File

@ -12,6 +12,12 @@
#include "libft.h"
/**
* @brief ft_isprint() checks if a character is a printable character.
*
* @param c contains an integer of the character to be tested.
* @return int returns c if the int codes for aprintable character.
*/
int ft_isprint(int c)
{
return (32 <= c && 126 >= c);

View File

@ -40,6 +40,13 @@ static void *free_arr(int n, char ***arr)
return (NULL);
}
/**
* @brief ft_split() splits an array based on a seperator.
*
* @param s is a string.
* @param c is the seperator.
* @return char** an array of string where the last element is NULL.
*/
char **ft_split(char const *s, char c)
{
char **result;

View File

@ -11,7 +11,14 @@
/* ************************************************************************** */
#include "libft.h"
/**
* @brief ft_strchr() return a pointer to the first char found in the string.
*
* @param s the string to be searched.
* @param c the character searched for.
* @return char* the pointer to the first char found in the string if
* nothing is foun ft_strchr() NULL.
*/
char *ft_strchr(const char *s, int c)
{
while (*s)

View File

@ -12,6 +12,14 @@
#include "libft.h"
/**
* @brief ft_strlcat() concatenates size bytes from src into dst
*
* @param dst the destination string.
* @param src the source string.
* @param size the amount of bytes to be copied into dst
* @return size_t the amount of bytes that should havebeen copied.
*/
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t src_len;

View File

@ -11,7 +11,12 @@
/* ************************************************************************** */
#include "libft.h"
/**
* @brief ft_strlen() return the length of a null-terminated string.
*
* @param s the string.
* @return size_t the length of the string.
*/
size_t ft_strlen(const char *s)
{
size_t length;