String length · ความยาว string
String length
A C-string is a row of characters that ends with a hidden null terminator. Return how many characters come before it — basically writing strlen yourself. Walk an index forward until you reach the terminator, counting as you go.
ความยาวสตริง
C-string คือชุดของตัวอักษรที่ลงท้ายด้วย null terminator ที่ซ่อนอยู่ คืนค่าว่ามีตัวอักษรกี่ตัวมาก่อนมัน — โดยพื้นฐานแล้วการเขียน strlen เอง เดิน index ไปข้างหน้าจนกว่าจะถึง terminator นับไปพร้อมกัน
Complete int str_len(const char *s) to return the length of the C-string s, without using strlen. Count characters until the null terminator. · เติม int str_len(const char *s) ให้กลับความยาวของ C-string s โดยไม่ ใช้ strlen นับตัวอักษรจนพบตัวจบ string (null terminator)
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่