1 #include<stdio.h>
2 #include<string.h>
3 #include<stdlib.h>
4 int main(int argc,char **argv)
5 {
6 int i,j,m=0,n=0;
7 char *src="a ab abc abcd abcde abcdef abcdefg abcdefgh abcdefghi abcdefghij abcdefghijk abcdefghijkl abcdefghijklm abcdefghijklmn abcdefghijklmno abcdefghijklmnop abcdefghijklmnopq abcdefghijklmnopq abcdefghijklmnopq abcdefghijklmnopq abcdefghijklmnopqr abcdefghijklmnopqrs abcdefghijklmnopqrst abcdefghijklmnopqrstuv abcdefghijklmnopqrstuvw abcdefghijklmnopqrstuvwx abcdefghijklmnopqrstuvwxy abcdefghijklmnopqrstuvwxyz";
8 char *des=argv[1];
9 if (argc<2)
10 {
11 printf("usage: %s str_des\n",argv[0]);
12 exit(1);
13 }
14 // printf("src=%s\n",src);
15 // printf("des=%s\n",des);
16 i=strlen(src);
17 j=strlen(des);
18 while((m=m-n+1)<i)
19 {
20 n=0;
21 while(src[m-1]==des[n])
22 {
23 if(n==j-1)
24 {
25 printf("the \"%s\" is fond in the src on %d\n",argv[1],m-n);
26 exit(0);
27 }
28 m++,n++;
29 }
30 }
31 printf("the \"%s\" is NOT in the src\n",argv[1]);
32 }