36 #define MAX_INT 2147483647
37 #define MIN_INT -2147483648
38 #define MAX_LONG 9223372036854775807
39 #define MIN_LONG -9223372036854775808
40 #define MAX_SHORT 32767
41 #define MIN_SHORT -32768
42 #define MAX_SHORT_SHORT 127
43 #define MIN_SHORT_SHORT -128
44 #define MAX_SIZE_T 18446744073709551615
48 #define ABS(value) ((value < 0) ? - value : value)
49 #define MAX(a, b) ((a > b) ? a : b)
50 #define MIN(a, b) ((a < b) ? a : b)
51 #define STR_CONTAINS(str, find) (my_strstr(str, find) != NULL) ? 1 : 0
52 #define NB number_settings_t
56 #define STR2ARRAY(str) my_str_to_word_array(str)
57 #define STR2ARRAY_SEP(str, sep) my_str_to_word_array_select(str, sep)
58 #define STR2ARRAY_STR(str, sep) my_str_to_word_array_string(str, sep)
62 #define FREE(ptr) ptr = my_free_ptr(ptr)
63 #define FREE_WORD_ARRAY(ptr) my_free_array((void **)ptr)
87 my_bool_t multiple_signe;
88 my_bool_t letter_before;
89 my_bool_t letter_after;
93 #define NB number_settings_t
245int my_fprintf(
int fd,
char const *format, ...);
355int my_str_is(
char *str,
const char *char_list);
385char *
my_strcpy(
char *dest,
char const *src);
397char *
my_strncpy(
char *dest,
char const *src,
int n);
417char *
my_strstr(
char *str,
char const *to_find);
427int my_strcmp(
char const *s1,
char const *s2);
438int my_strncmp(
char const *s1,
char const *s2,
int n);
473char *
my_strcat(
char *dest,
char const *src);
484char *
my_strncat(
char *dest,
char const *src,
int nb);
588 char const *base_from,
char const *base_to);
600 char const *base_from,
char const *base_to);
612 char const *base_from,
char const *base_to);
char * my_str_nbr_base_unsigned_long(unsigned long nbr, char const *base)
Returns the string conversion of an unsigned long number (nbr) in specific base (base)
Definition my_str_nbr_base_unsigned_long.c:30
char * my_str_nbr(int nb)
Returns the string conversion of a number (nb)
Definition my_str_nbr.c:31
void my_sort_params(int argc, char **argv)
Sorts the parameters (argc and argv) in ascending order.
Definition my_sort_params.c:52
void my_show_word_array(char *const *tab)
Prints all word in an array (tab)
Definition my_show_word_array.c:15
void my_showstr(char const *str)
Prints a string (str) but replaces non-printable characters with their hexadecimal number.
Definition my_showstr.c:22
int my_putstr_fd_free(char *str, int fd)
Writes a string (str) in a file descriptor (fd), free it and returns the length of the printed string...
Definition my_putstr_fd_free.c:16
int my_str_islower(char const *str)
Checks if a string (str) is lowercase.
Definition my_str_islower.c:16
void my_show_param_array(struct info_param const *par)
Prints the information of a parameter array (par)
Definition my_show_param_array.c:16
int my_compute_power_rec(int nb, int power)
Returns the power (p) of the number (nb)
Definition my_compute_power_rec.c:15
int my_strcmp(char const *s1, char const *s2)
Compares two strings (s1) and (s2)
Definition my_strcmp.c:16
char * my_strndup(const char *src, int n)
Duplicates a string (src) with a defined size (n) and returns the new string.
Definition my_strndup.c:15
void my_putnbr_base(int nbr, char const *base)
Prints a number (nb) in the requested base (base) in stdout.
Definition my_putnbr_base.c:28
int my_find_prime_inf(int nb)
Returns the previous prime number before a number (nb)
Definition my_find_prime_inf.c:15
char * my_strcpy(char *dest, char const *src)
Copies a string (src) and paste it on another string (dest)
Definition my_strcpy.c:15
void my_putnbr(int nb)
Prints a number (nb) in stdout.
Definition my_putnbr.c:28
int my_strict_getnbr(char const *str)
Returns an int number starting from a string number (str)
Definition my_strict_getnbr.c:16
int my_compute_square_root(int nb)
Returns the square root of a number (nb)
Definition my_compute_square_root.c:15
void my_print_params(int argc, char **argv)
Prints all the parameters of the program.
Definition my_print_params.c:15
void my_sort_int_array(int *tab, int size)
Sorts an array (array) with a defined size (size) of integers in ascending order.
Definition my_sort_int_array.c:25
void my_swap(int *a, int *b)
Swaps two integers (a) and (b)
Definition my_swap.c:15
void my_replace_char(char *str, char to_replace, char replace_by)
Replace a char in a string by another char.
Definition my_replace_char.c:15
int my_putstr_fd(char const *str, int fd)
Writes a string (str) in a file descriptor (fd) and returns the length of the printed string.
Definition my_putstr_fd.c:16
int my_is_prime(int nb)
Returns 1 if the number (nb) is prime and 0 otherwise.
Definition my_is_prime.c:15
char * my_str_nbr_unsigned_long(unsigned long int nb)
Returns the string conversion of an unsigned long number (nb)
Definition my_str_nbr_unsigned_long.c:30
int my_strlen(char const *str)
Returns the length of a string (str)
Definition my_strlen.c:15
int my_char_is(char c, const char *char_list)
Checks if a char (c) is in a list of chars (char_list)
Definition my_char_is.c:16
char * my_strncpy(char *dest, char const *src, int n)
Copies a string (src) and paste it on another string (dest) with a defined size (n)
Definition my_strncpy.c:16
char * my_str_nbr_short_short(signed char nb)
Returns the string conversion of a short short number (nb)
Definition my_str_nbr_short_short.c:31
char * my_strupcase(char *str)
Replaces lowcase by upcase of a string (str)
Definition my_strupcase.c:15
int my_find_nbr(char const *str)
Find the first number (number) found in a string.
Definition my_find_nbr.c:15
int my_strncmp(char const *s1, char const *s2, int n)
Compares two strings (s1) and (s2) with a defined size (n)
Definition my_strncmp.c:16
int my_str_is(char *str, const char *char_list)
Checks if a string (str) is composed of characters in the characters list (char_list) or 0 if not.
Definition my_str_is.c:16
int my_array_len(void **array)
Returns the length of an array (array)
Definition my_array_len.c:15
int my_str_isprintable(char const *str)
Checks if a string (str) is printable.
Definition my_str_isprintable.c:15
void my_print_combn(int n)
Prints all the numbers composed by (n) different digits numbers All digits in the number are differen...
Definition my_print_combn.c:56
float my_getnbr_float(char const *str)
Returns a float number starting from a string number (str)
Definition my_getnbr_float.c:24
char ** my_str_to_word_array_select(char const *str, char const *separator)
Returns an array of words delimited by a list of separator (separator) from a string (str)
Definition my_str_to_word_array_select.c:76
char ** my_strdup_word_array(char **array)
Duplicates a word array (array) and returns the new array.
Definition my_strdup_word_array.c:15
char * my_strcapitalize(char *str)
Capitalizes the first letter of each word in a string (str) and lowercase the other letters.
Definition my_strcapitalize.c:15
int my_str_isnum(char const *str)
Checks if a string (str) is a number.
Definition my_str_isnum.c:15
void my_rev_params(int argc, char **argv)
Prints all the arguments (argc and argv) in reverse order.
Definition my_rev_params.c:15
char * my_strstr(char *str, char const *to_find)
Search a string (to_find) on another (str) and returns the address of the first occurrence.
Definition my_strstr.c:16
int my_get_char_index(char *str, char c, int occurrence)
Get the index of a char in a str according to its occurrence.
Definition my_get_char_index.c:15
int my_count_letter(char const *str, char c)
Counts the number of times a letter (c) is in a string (str)
Definition my_count_letter.c:15
int my_str_contains(char *str, char *char_list)
Checks if a string (str) contains a character in a list of characters (char_list)
Definition my_str_contains.c:25
size_t my_compute_power_rec_size_t(int nb, int p)
Returns the power (p) of the number (nb)
Definition my_compute_power_rec_size_t.c:15
char * my_add_chr(char *str, char chr)
Adds a char (chr) at the end of a string (str)
Definition my_add_chr.c:15
int my_str_isupper(char const *str)
Checks if a string (str) is uppercase.
Definition my_str_isupper.c:16
char * my_str_nbr_base_long_long_int(long long int nbr, char const *base)
Returns the string conversion of an long long number (nbr) in specific base (base)
Definition my_str_nbr_base_long_long_int.c:30
char * my_convert_base_unsigned(char const *nbr, char const *base_from, char const *base_to)
Returns the result of the conversion of a unsigned number (nbr) in a specific base (base_from) to ano...
Definition my_convert_base_unsigned.c:84
char * my_str_nbr_base_unsigned_short_short(unsigned char nbr, char const *base)
Returns the string conversion of an unsigned short short number (nbr) in specific base (base)
Definition my_str_nbr_base_unsigned_short_short.c:30
char * my_strncat(char *dest, char const *src, int nb)
Concatenates two strings (dest) and (src) with a defined size (nb)
Definition my_strncat.c:16
char * my_strlowcase(char *str)
Replaces upcase by lowcase of a string (str)
Definition my_strlowcase.c:15
char * my_str_nbr_base_unsigned(unsigned int nbr, char const *base)
Returns the string conversion of an unsigned number (nbr) in specific base (base)
Definition my_str_nbr_base_unsigned.c:30
int my_getnbr(char const *str)
Returns an int number starting from a string number (str)
Definition my_getnbr.c:24
int my_compute_factorial_rec(int nb)
Returns the factorial of a number (nb)
Definition my_compute_factorial_rec.c:15
int my_char_is_alpha(char const c)
Checks if a char (c) is a letter.
Definition my_char_is_alpha.c:15
int my_printf(char const *format,...)
Prints a string (format) with possible flags and format in stdout and returns the length the printed ...
Definition my_printf.c:87
int my_putstr_error(char const *str)
Prints a string (str) in stderr.
Definition my_putstr_error.c:15
char * my_str_nbr_size_t(size_t nb)
Returns the string conversion of an size_t number (nb)
Definition my_str_nbr_size_t.c:29
void my_isneg(int nb)
Prints 'P' if the number (n) is positive or 'N' if the number (n) is negative.
Definition my_isneg.c:16
void * my_free_ptr(void *ptr)
Frees a pointer (ptr)
Definition my_free_ptr.c:15
char * my_str_nbr_short(short int nb)
Returns the string conversion of a short number (nb)
Definition my_str_nbr_short.c:31
struct info_param * my_params_to_array(int ac, char **av)
Returns a info_params struct of the argc (ac) and the argv (av)
Definition my_params_to_array.c:15
char * my_concat_params(int argc, char **argv)
Returns a string with all the arguments (argc and argv) concatenated.
Definition my_concat_params.c:15
char * my_strcat(char *dest, char const *src)
Concatenates two strings (dest) and (src)
Definition my_strcat.c:16
char * my_convert_base(char const *nbr, char const *base_from, char const *base_to)
Returns the result of the conversion of a number (nbr) in a specific base (base_from) to another base...
Definition my_convert_base.c:52
char ** my_super_array(char *str, char *sep)
Returns an array of words delimited by a list of separator (separator) from a string (str)
Definition my_super_array.c:74
int my_putstr_sized(char const *str, int size)
Prints a string (str) in stdout with a defined size (size) and returns the length of the printed stri...
Definition my_putstr_sized.c:16
void my_showmem(char const *str, int size)
Prints a memory dump of a string (str) with a defined size.
Definition my_showmem.c:81
void my_free_array(void **array)
Frees an array (array)
Definition my_free_array.c:15
char ** my_str_to_word_array_string(char const *str, char const *separator)
Returns an array of words delimited by a separator (separator) from a string (str)
Definition my_str_to_word_array_string.c:74
char * my_strdup(const char *src)
Duplicates a string (src) and returns the new string.
Definition my_strdup.c:15
char * my_str_nbr_unsigned(unsigned int nb)
Returns the string conversion of an unsigned number (nb)
Definition my_str_nbr_unsigned.c:29
float my_strict_getnbr_float(char const *str)
Returns a float number starting from a string number (str)
Definition my_strict_getnbr_float.c:16
const char * my_strerror(int error)
Returns the error message of the error number (error)
Definition my_strerror.c:149
char my_get_last_char(char *str)
Returns the last char of a string (str)
Definition my_get_last_char.c:15
void my_putchar(char c)
Prints a char (c) in the stdout.
Definition my_putchar.c:15
char ** my_str_to_word_array(char const *str)
Returns an array of words from a string (str)
Definition my_str_to_word_array.c:68
int my_char_is_num(char const c)
Checks if a char (c) is a number.
Definition my_char_is_num.c:15
int my_putstr(char const *str)
Writes a string (str) in stdout and returns the length of the printed string.
Definition my_putstr.c:16
char * my_convert_base_size_t(char const *nbr, char const *base_from, char const *base_to)
Returns the result of the conversion of a size_t number (nbr) in a specific base (base_from) to anoth...
Definition my_convert_base_size_t.c:84
char * my_str_nbr_base_unsigned_short(unsigned short nbr, char const *base)
Returns the string conversion of an unsigned short number (nbr) in specific base (base)
Definition my_str_nbr_base_unsigned_short.c:30
int my_char_is_printable(char const c)
Checks if a char (c) is printable.
Definition my_char_is_printable.c:15
int my_fprintf(int fd, char const *format,...)
Writes a string (format) with possible flags and format in a file descriptor (fd) and returns the len...
Definition my_fprintf.c:87
char * my_str_nbr_base_unsigned_size_t(size_t nbr, char const *base)
Returns the string conversion of an size_t number (nbr) in specific base (base)
Definition my_str_nbr_base_unsigned_size_t.c:30
char * my_str_nbr_long_long(long long nb)
Returns the string conversion of an long long number (nb)
int my_getnbr_base(char const *str, char const *base)
Returns a number starting from a string number (str) in the requested base (base)
Definition my_getnbr_base.c:45
int my_str_isalpha(char const *str)
Checks if a string (str) is alphabetical.
Definition my_str_isalpha.c:15
int my_super_number(char *number, number_settings_t settings)
Returns an int number starting from a string number (number) and change my_errno if an error occurs d...
Definition my_super_number.c:45
char * my_revstr(char *str)
Reverses the characters in a string (str) and returns the string (str)
Definition my_revstr.c:15
void my_round_float_str(char *float_nb, char last_char, int i, int enable)
Modify a string (float) and round it.
Definition my_round_float_str.c:29
int my_strict_find_nbr(char const *str)
Find the first number (number) found in a string.
Definition my_strict_find_nbr.c:16
int my_nbrlen(int nb)
Returns the length of a number (nb)
Definition my_nbrlen.c:15
int my_find_prime_sup(int nb)
Returns the next prime number after a number (nb)
Definition my_find_prime_sup.c:15