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