Question #342876

Write function headers for the functions described below:

(iv) The function countChar returns the number of occurrences of a character in a string, both provided as parameters


Expert's answer

int countChar(char character, char* text){
    int counter =0;


    for(int i =0; i<sizeof(text)/sizeof(text[0]) ;i++){
        if(text[i]==character)  counter++;
    }
    return counter;
}

LATEST TUTORIALS
APPROVED BY CLIENTS