find_prefix_char_number

 

Description

Find the repeat appearance times of the prefix character at the beginning of a string.

Syntax

int find_prefix_char_number( const string & str, char ch )

Parameters

str
[input]string to be counted
ch
[input]character to be found in str

Return

the repeat appearance times of the prefix char at the beginning of of a string.

Examples

EX1

void find_prefix_char_number_ex1()
{
    string str = "pppabcde";
    char pch = 'p';
    //Change 'p' to other char to see different result 
    int nRet = find_prefix_char_number(str, pch);
    if(nRet)
    printf("Prefix char \'%c\' repeat %d times in \"%s\" \n" ,pch,nRet,str);
    else
    printf("\'%c\' is not the prefix char in \"%s\"\n" ,pch,str);  
}

Remark

See Also

find_end_char_number

header to Include

origin.h

Reference