Count a character · 统计某个字符
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
English
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.
中文
统计某个字符
返回某个字符在 C 字符串中出现的次数。遍历字符直到空字符为止,每当当前字符与 target 相同时就加 1。
Complete int count_char(const char *s, char target) to return how many times target appears in the C-string s. · 完成 int count_char(const char *s, char target),返回 target 在 C 字符串 s 中出现的次数。
Click Run to see the output here. · 点击“运行”查看此处输出。