- 通过示例学习 C 语言 时间
- 通过示例学习 C 语言 - 主页
- C 示例 - 简单程序
- C 示例 - 循环/迭代
- C 示例 - 模式
- C 示例 - 数组
- C 示例 - 字符串
- C 示例 - 数学
- C 示例 - 链表
C语言字符串长度程序
实施
现在,我们将看到程序的实际实施 -
#include <stdio.h>
int main() {
char s1[] = "TajMahal";
int i = 0;
while(s1[i] != '\0') {
i++;
}
printf("Length of string '%s' is %d", s1, i);
return 0;
}
输出
此程序的输出应该是 -
Length of string 'TajMahal' is 8
string_programs_in_c.htm
广告