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ストリング内で何回出現するかを返します。nul終端文字まで文字をループさせ、現在の文字が target と一致したたびに1加算します。
Complete int count_char(const char *s, char target) to return how many times target appears in the C-string s.
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。