| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | ** EPITECH PROJECT, 2023 | ||
| 3 | ** my_strstr | ||
| 4 | ** File description: | ||
| 5 | ** Search a string (to_find) on another (str) | ||
| 6 | ** and returns the address of the first occurrence | ||
| 7 | */ | ||
| 8 | /** | ||
| 9 | * @file my_strstr.c | ||
| 10 | * @brief The file containing the my_strstr function | ||
| 11 | * @author Nicolas TORO | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include "my.h" | ||
| 15 | |||
| 16 | 3 | char *my_strstr(char *str, char const *to_find) | |
| 17 | { | ||
| 18 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
|
3 | if (my_strlen(to_find) == 0) |
| 19 | 1 | return str; | |
| 20 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
|
8 | for (int i = 0; str[i] != '\0'; i++) { |
| 21 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 3 taken 6 times.
|
7 | if (my_strncmp(&str[i], to_find, my_strlen(to_find)) == 0) |
| 22 | 1 | return &str[i]; | |
| 23 | } | ||
| 24 | 1 | return NULL; | |
| 25 | } | ||
| 26 |