Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2023 | ||
3 | ** my_strcapitalize | ||
4 | ** File description: | ||
5 | ** Capitalizes the first letter of each word in a string (str) | ||
6 | */ | ||
7 | /** | ||
8 | * @file my_strcapitalize.c | ||
9 | * @brief The file containing the my_strcapitalize function | ||
10 | * @author Nicolas TORO | ||
11 | */ | ||
12 | |||
13 | #include "my.h" | ||
14 | |||
15 | 1 | char *my_strcapitalize(char *str) | |
16 | { | ||
17 | 1 | str = my_strlowcase(str); | |
18 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (int i = 1; str[i] != '\0'; i++) { |
19 |
4/6✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 3 times.
|
4 | if (((str[i - 1] == '+' || str[i - 1] == '-' || str[i - 1] == ' ')) |
20 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | && (str[i] >= 'a' && str[i] <= 'z')) |
21 | 1 | str[i] = str[i] - 32; | |
22 | } | ||
23 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | if (str[0] >= 'a' && str[0] <= 'z') |
24 | 1 | str[0] = str[0] - 32; | |
25 | 1 | return str; | |
26 | } | ||
27 |