Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <stdlib.h>
- int main()
- {
- int i,j,c=0;
- int g,t=1,n=0;
- char a[10];
- char l[200];
- printf("enter your line \n");
- gets(l);
- printf("enter your word \n");
- scanf("%s",a);
- for(i=0;i<10;i++)
- {
- if(a[i]==0)
- {
- break;
- }
- else
- {
- c++;
- }
- }
- for(i=0;i<200;i++)
- {
- t=1;
- if(a[0]==l[i])
- {
- for(j=1;j<c;j++)
- {
- if(a[j]==l[i+j])
- {
- t=0;
- }
- else
- {
- t=1;
- break;
- }
- }
- }
- if(t==0)
- {
- n++;
- printf("%d",n);
- printf("occurrence at index %d \n",i);
- }
- }
- printf("total occurrence %d \n",n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement