Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2023 | ||
3 | ** my_strncpm | ||
4 | ** File description: | ||
5 | ** return int but comparing only to n elements | ||
6 | */ | ||
7 | |||
8 | #include "my.h" | ||
9 | |||
10 | 10 | int my_strncmp(char const *s1, char const *s2, int n) | |
11 | { | ||
12 | 10 | int i = 0; | |
13 | |||
14 |
5/6✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 19 times.
✗ Branch 5 not taken.
|
21 | while (s1[i] != '\0' && s2[i] != '\0' && i < n) { |
15 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 11 times.
|
19 | if (s1[i] != s2[i]) |
16 | 8 | return (s1[i] - s2[i]); | |
17 | 11 | i++; | |
18 | } | ||
19 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (i == n) |
20 | 2 | return 0; | |
21 | ✗ | return s1[i] - s2[i]; | |
22 | } | ||
23 |