Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- author: sid
- search arg 2 in arg 1
- */
- #include<stdio.h>
- #include<string.h>
- int main(int argc, char **argv)
- {
- if(argc != 3)
- {
- printf("usage %s: <hay_string> <needle_string>\n",argv[0]);
- return;
- }
- char word[100];
- int wc = 0;
- int found = 0;
- int i = 0;
- for(; i < strlen(argv[1]); i++)
- {
- if(isspace(argv[1][i]))
- {
- word[wc] = '\0';
- if(strstr(word,argv[2]))
- found++;
- wc = 0;
- }
- word[wc++] = argv[1][i];
- }
- printf("%s found %d times\n",argv[2],found);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement