diff --git a/AcquiringLand/Fundamentals/insert_string.c b/AcquiringLand/Fundamentals/insert_string.c new file mode 100644 index 0000000..3ad218b --- /dev/null +++ b/AcquiringLand/Fundamentals/insert_string.c @@ -0,0 +1,15 @@ +#include +#include + +char **insert_string(char **strings_array, int *array_size, char *insert_str, int index){ + + + char **rslt = malloc(array_size + 1 * sizeof(char)); + + int index = 0; + while (*(strings_array + index)){ + + + } + +} diff --git a/AcquiringLand/Fundamentals/itoa.c b/AcquiringLand/Fundamentals/itoa.c new file mode 100644 index 0000000..766a9a7 --- /dev/null +++ b/AcquiringLand/Fundamentals/itoa.c @@ -0,0 +1,69 @@ +#include +#include + +int get_number_length(int value){ + + if (value > 0 && value < 10) return 1; + + int clc = 0; + if (value < 0) { + value = value * -1; + clc ++; + } + while (value > 10 ){ + clc ++; + value = value / 10; + } + + return clc + 1; +} + +char *my_itoa(int value){ + + int taille = get_number_length(value); + + char *rslt = malloc(taille + 1 * sizeof(char)); + + if (value < 0){ + value = value * -1; + *rslt = '-'; + } + + *(rslt + taille) = '\0'; + + if(value < 10){ + if( *rslt == '-')*(rslt + 1) = value + 48; + else *(rslt) = value + 48; + return rslt; + } + + taille --; + while (taille > 0){ + *(rslt + taille) = 48 +value % 10; + value = value / 10; + taille --; + } + + return rslt; +} + +int main(){ + printf("TESTS 1 \n"); + printf("%i\n", get_number_length(7)); //1 + printf("%i\n",get_number_length(-97163)); //6 + printf("%i\n",get_number_length(82622)); //5 + + printf("TESTS 2\n"); + char *rslt = ""; + + rslt = my_itoa(-172); // "-172" + printf("%s\n", rslt); + free(rslt); + rslt = my_itoa(2); // "2" + printf("%s\n", rslt); + free(rslt); + rslt = my_itoa(-2829302); // "-2829302" + printf("%s\n", rslt); + free(rslt); + +} diff --git a/AcquiringLand/Fundamentals/join_strings.c b/AcquiringLand/Fundamentals/join_strings.c new file mode 100644 index 0000000..e69de29 diff --git a/AcquiringLand/Fundamentals/magic_arrays.c b/AcquiringLand/Fundamentals/magic_arrays.c new file mode 100644 index 0000000..e69de29 diff --git a/AcquiringLand/Fundamentals/minefield.c b/AcquiringLand/Fundamentals/minefield.c index 48c1dad..36cbc1b 100644 --- a/AcquiringLand/Fundamentals/minefield.c +++ b/AcquiringLand/Fundamentals/minefield.c @@ -101,7 +101,7 @@ void hash_map_free(struct hash_map *hash_map) } free(hash_map->data); free(hash_map); - hash_map->data = NULL; + //hash_map->data = NULL; } void hash_map_dump(struct hash_map *hash_map) @@ -160,8 +160,9 @@ bool hash_map_remove(struct hash_map *hash_map, const char *key) prev->next = elt->next; else hash_map->data[hashed_val] = elt->next; - free(elt); + //free(elt); printf("removed %s", elt->value); + free(elt); return true; } diff --git a/AcquiringLand/Proficiencies/normalize_array.c b/AcquiringLand/Proficiencies/normalize_array.c new file mode 100644 index 0000000..e69de29 diff --git a/AcquiringLand/Proficiencies/split_by_sum.c b/AcquiringLand/Proficiencies/split_by_sum.c new file mode 100644 index 0000000..e69de29 diff --git a/AcquiringLand/Proficiencies/unique_words.c b/AcquiringLand/Proficiencies/unique_words.c new file mode 100644 index 0000000..e69de29