| 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 | 5 | char *my_strstr(char *str, char const *to_find) | |
| 17 | { | ||
| 18 | 4/4✓ Branch 0 taken 4 times. ✓ Branch 1 taken 1 times. ✓ Branch 2 taken 1 times. ✓ Branch 3 taken 3 times. | 5 | if (str == NULL || to_find == NULL) | 
| 19 | 2 | return NULL; | |
| 20 | 2/2✓ Branch 1 taken 1 times. ✓ Branch 2 taken 2 times. | 3 | if (my_strlen(to_find) == 0) | 
| 21 | 1 | return str; | |
| 22 | 2/2✓ Branch 0 taken 7 times. ✓ Branch 1 taken 1 times. | 8 | for (int i = 0; str[i] != '\0'; i++) { | 
| 23 | 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) | 
| 24 | 1 | return &str[i]; | |
| 25 | } | ||
| 26 | 1 | return NULL; | |
| 27 | } | ||
| 28 |