/ * ** strstr.c ** * / #include <stdio.h> #include < String .h> // find the number in the string abcd appears p // custom function interface on the separate business functions and main function int getCount ( char * myStr, char * Sub, int * nCount) { int RET = 0 ; IF (Sub myStr == == NULL NULL || || nCount == NULL) { RET = - . 1 ; the printf ( " One of IS NULL Point \ n- " ); return RET; } main ()int tmpCount = 0 ; char * P = myStr; // Do not modify the parameter values do { P = Strstr (P, Sub); IF (! P = NULL) { tmpCount ++ ; P = P + strlen (Sub ); } the else { BREAK ; } } the while (* = P! ' \ 0 ' ); * = nCount tmpCount; // indirect assignment greatest significance is the presence of a pointer return RET; } int { int ret = 0; char *p = "abcd11122abcd3333abcd3456abc"; int count = 0; char sub[] = "abcd"; ret = getCount(p,sub,&count); if(ret != 0) { printf("getCount error ret:%d\n",ret); return ret; } printf("count:%d\n",count); return 0; }