串的模式匹配问题

/* 以下程序在Dev-C++中编译通过,结果正确 */ #include #include main() { int findStr(char *str, char *substr); int n; char str[80]="iloueywouaieywoowou32ouueuoououyiooouuouo"; char substr[3]="ou"; printf ("The original string is :/n/n"); puts (str); printf ("/nThe substr is :/n"); puts (substr); n=findStr(str,substr); printf ("Substr counted is %d", n); getch(); } int findStr(char *str, char *substr) { int n=0,i=0,j=0; while (*(str+i)!='/0') { if (*(str+i)==*(substr+j)) {i++; j++;} else {i=i-j+1; j=0;} if (*(substr+j)=='/0') {n++; j=0;} } return n; }  

你可能感兴趣的:(Linux/Unix,安全,黑客,string)