| 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 | * @file my_revstr.c | ||
| 9 | * @brief The file containing the my_revstr function | ||
| 10 | * @author Nicolas TORO | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include "my.h" | ||
| 14 | |||
| 15 | 851 | char *my_revstr(char *str) | |
| 16 | { | ||
| 17 | 851 | int len = 0; | |
| 18 | char temp; | ||
| 19 | |||
| 20 |
2/2✓ Branch 0 taken 2677 times.
✓ Branch 1 taken 851 times.
|
3528 | while (str[len] != '\0') |
| 21 | 2677 | len = len + 1; | |
| 22 |
2/2✓ Branch 0 taken 1050 times.
✓ Branch 1 taken 851 times.
|
1901 | for (int i = len / 2; i > 0; i--) { |
| 23 | 1050 | temp = str[i - 1]; | |
| 24 | 1050 | str[i - 1] = str[len - i]; | |
| 25 | 1050 | str[len - i] = temp; | |
| 26 | } | ||
| 27 | 851 | return str; | |
| 28 | } | ||
| 29 |