2.32 model - the number of queries to specify the content that appears in a string

[Note: This program is verified using vs2013 version]

 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma warning(disable:4996)

int my_strAppoints(char *src, char *Specify, char *n){
    char *from = src;
    char *equal = Specify;
    int frequency = 0;
    if (*from == 0){ return -1; }

    while (1){
        fromStrstr = ( from , equal is); // strstr (): Query first address specified content appearing in memory and returns the address of the first
         IF ( from ! = NULL) {
             from = from + strlen (equal is); // re set the start position 
            Frequency ++ ; 
        } 
        the else { // if the end symbol 
            * = n- Frequency;
             return  0 ; 
        } 
    } 
} 

int main ( void ) {
     char * P = " 11abcd1235abcd 5abcd5 ++ + 53414 " ;
     int= Times 0 ; // number of occurrence of the string 
    int RET = 0 ; 

    RET = my_strAppoints (p, " ABCD " , & Times); // number of occurrences in the query p abcd, where the number of required delivery address 
    IF (RET =! 0 ) { 
        the printf ( " my_strAppoints ERR:% D \ n- " , RET);
         return ; 
    } 
    the printf ( " Times =% D \ n- " , Times); 
   the printf (
" \ n- " ); System ( " PAUSE " ); return 0; }

 

Guess you like

Origin www.cnblogs.com/wlstm/p/11105491.html