| 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 | 914 | char *my_revstr(char *str) | |
| 16 | { | ||
| 17 | 914 | int len = 0; | |
| 18 | char temp; | ||
| 19 | |||
| 20 | 2/2✓ Branch 0 taken 2809 times. ✓ Branch 1 taken 914 times. | 3723 | while (str[len] != '\0') | 
| 21 | 2809 | len = len + 1; | |
| 22 | 2/2✓ Branch 0 taken 1098 times. ✓ Branch 1 taken 914 times. | 2012 | for (int i = len / 2; i > 0; i--) { | 
| 23 | 1098 | temp = str[i - 1]; | |
| 24 | 1098 | str[i - 1] = str[len - i]; | |
| 25 | 1098 | str[len - i] = temp; | |
| 26 | } | ||
| 27 | 914 | return str; | |
| 28 | } | ||
| 29 |