Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C Compiler.
- Code, Compile, Run and Debug C program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- char input[100] = "fuck me daddy";
- char substr[3] = "dad";
- int s = 0;
- int w = 0;
- for (;s != strlen(input) && w != strlen(substr)-1; ++s)
- {
- if (input[s] != substr[w])
- {
- w = 0;
- }
- else
- {
- w++;
- }
- }
- if (w == strlen(substr)-1)
- printf("Found substring at position %d",s);
- else
- printf("not found\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement