#include <stdio.h>
int strLength(char s[]) {
int n = 0;
while (s[n] != '\0') {
n++;
}
return n;
}
int main() {
char str1[] = "Hello, world!"; // 字符串常量
char str2[10] = "Hello"; // 字符数组
char str3[] = ""; // 空字符串
printf("Length of str1: %d\n", strLength(str1)); // 输出:Length of str1: 13
printf("Length of str2: %d\n", strLength(str2)); // 输出:Length of str2: 5
printf("Length of str3: %d\n", strLength(str3)); // 输出:Length of str3: 0
return 0;
}