Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<conio.h>
- #include<iostream.h>
- #include<stdio.h>
- #include<string.h>
- void main ()
- {
- clrscr();
- char a[100] , b[10],c[10];
- int counter = 0;
- cout<<"please enter a string : ";
- gets(a);
- cout<<"please enter a word to look for : ";
- gets(b);
- for(int i = 0 ; i<strlen(a);i++){
- for(int j = 0 ; a[i]!=' ' && a[i]!='\0' ; i++,j++)
- c[j] = a[i];
- c[j] ='\0';
- if(strcmp(c,b)==0)
- counter++;
- }
- cout<<endl<<"the number of times the is "<<counter;
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment