Skip to content

Instantly share code, notes, and snippets.

@MaratB
Last active December 25, 2015 17:19
Show Gist options
  • Save MaratB/7011838 to your computer and use it in GitHub Desktop.
Save MaratB/7011838 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <conio.h>
main(){
char s[80], word[30].
*p;
int count=0, len;
printf("Enter sentence: %s\n", s );
gets(s);
printf("Enter word: %s\n", word );
gets (word);
len = strlen(word);
p = s;
while(1){
p = strstr(p, word);
if (p==0) break;
p = p+len;
count++;
}
printf(" %d %s in this sentence\n", count, word );
getch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment