| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | ** EPITECH PROJECT, 2023 | ||
| 3 | ** my_revstr | ||
| 4 | ** File description: | ||
| 5 | ** Reverses the characters in a string (str) and returns the string (str) | ||
| 6 | */ | ||
| 7 | |||
| 8 | 791 | char *my_revstr(char *str) | |
| 9 | { | ||
| 10 | 791 | int len = 0; | |
| 11 | char temp; | ||
| 12 | |||
| 13 |
2/2✓ Branch 0 taken 2463 times.
✓ Branch 1 taken 791 times.
|
3254 | while (str[len] != '\0') { |
| 14 | 2463 | len = len + 1; | |
| 15 | } | ||
| 16 |
2/2✓ Branch 0 taken 968 times.
✓ Branch 1 taken 791 times.
|
1759 | for (int i = len / 2; i > 0; i--) { |
| 17 | 968 | temp = str[i - 1]; | |
| 18 | 968 | str[i - 1] = str[len - i]; | |
| 19 | 968 | str[len - i] = temp; | |
| 20 | } | ||
| 21 | 791 | return str; | |
| 22 | } | ||
| 23 |