Count a character · นับ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-stringวนลูปผ่านตัวอักษรจนกว่าจะถึง null terminator เพิ่ม 1 ในแต่ละครั้งที่ตัวอักษรปัจจุบันตรงกับ target
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-string s
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่