Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int substring(char src[], char str[]) {
- int i, j, firstOcc;
- i = 0, j = 0;
- while (src[i] != '\0') {
- while (src[i] != str[0] && src[i] != '\0')
- i++;
- if (src[i] == '\0')
- return (0);
- firstOcc = i;
- while (src[i] == str[j] && src[i] != '\0' && str[j] != '\0') {
- i++;
- j++;
- }
- if (str[j] == '\0')
- return (1);
- if (src[i] == '\0')
- return (0);
- i = firstOcc + 1;
- j = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment