Count a character · Compter un caractère
Count a character
Return how many times a given character appears in a C-string. Loop over the characters until the null terminator, adding 1 each time the current character matches target.
Compter un caractère
Retournez combien de fois un caractère donné apparaît dans une chaîne C. Bouclez sur les caractères jusqu'au terminateur nul, en ajoutant 1 chaque fois que le caractère actuel correspond à target.
Complete int count_char(const char *s, char target) to return how many times target appears in the C-string s. · Complétez int count_char(const char *s, char target) pour retourner combien de fois target apparaît dans la chaîne C s.
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.