String length · 字符串长度
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
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 字符串是一串字符,以一个隐藏的空字符(null 终止符)结尾。返回它前面有多少个字符 —— 其实就是自己实现 strlen。用一个下标向前走,一直走到终止符为止,边走边数。
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 字符串 s 的长度,不要使用 strlen。一直数到空字符(null 终止符)为止。
Click Run to see the output here. · 点击“运行”查看此处输出。