strstr

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    char *p = "abcedabc";
    int n = 0;
    do{
        p = strstr(p, "ab");
        if (p != NULL){
            n++;
            p = p + strlen("ab");
        }
        else{
            break;
        }

    } while (*p != 0);
    printf("n=%d", n);
    printf("\n");
    system("pause");

    return 0;
}
 

猜你喜欢

转载自blog.csdn.net/u013988442/article/details/84066024