题出自---------------------------------零基础学C语言
#include<stdio.h>
int main()
{
int word = 0;
char a[100];
int i;
puts("请输入字符串:");
gets_s(a);/*接受字符串用gets_s()*/
if (a[0] == '\0')
word = 0;
else
for(i = 0; a[i] != '\0'; i++)
word++;
puts("字符串中字符个数为:");
printf("%d个\n", word);
return 0;
}
tip: 该计算原理不包含计算机默认的最后一个字符串‘\0’