GCC Code Coverage Report


Directory: ./
File: lib/my/my_revstr.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 9 9 100.0%
Functions: 1 1 100.0%
Branches: 4 4 100.0%

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 936 char *my_revstr(char *str)
16 {
17 936 int len = 0;
18 char temp;
19
20
2/2
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 936 times.
3767 while (str[len] != '\0')
21 2831 len = len + 1;
22
2/2
✓ Branch 0 taken 1098 times.
✓ Branch 1 taken 936 times.
2034 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 936 return str;
28 }
29