| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | ** EPITECH PROJECT, 2023 | ||
| 3 | ** my_str_nbr_unsigned_long | ||
| 4 | ** File description: | ||
| 5 | ** Returns the strings convertion of a long unsigned number (nb) | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include "my.h" | ||
| 9 | |||
| 10 | 1 | static char *set_str_nb_unsigned_long(unsigned long int nb, | |
| 11 | int int_nb) | ||
| 12 | { | ||
| 13 | 1 | char *nb_str = malloc(sizeof(char) * (int_nb + 1)); | |
| 14 | 1 | int j = 0; | |
| 15 | 1 | unsigned long int figure_temp = nb; | |
| 16 | |||
| 17 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for (j = 0; j < int_nb; j++) { |
| 18 | 2 | nb_str[j] = 48 + (figure_temp % 10); | |
| 19 | 2 | figure_temp = (figure_temp - (figure_temp % 10)) / 10; | |
| 20 | } | ||
| 21 | 1 | nb_str[j] = '\0'; | |
| 22 | 1 | return my_revstr(nb_str); | |
| 23 | } | ||
| 24 | |||
| 25 | 1 | char *my_str_nbr_unsigned_long(unsigned long int nb) | |
| 26 | { | ||
| 27 | 1 | int int_nb = 1; | |
| 28 | 1 | unsigned long int temp_nb = nb; | |
| 29 | |||
| 30 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | while ((temp_nb / 10) != 0) { |
| 31 | 1 | int_nb = int_nb + 1; | |
| 32 | 1 | temp_nb = temp_nb / 10; | |
| 33 | } | ||
| 34 | 1 | return set_str_nb_unsigned_long(nb, int_nb); | |
| 35 | } | ||
| 36 |