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
现在,我们将看到程序的实际实施 −
#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
如果您发现内容有误或提出修改建议,请随时向我们发送 E-mail 邮件:
421660149@qq.com
您的建议已发送到 W3schools。