从键盘任意输入一个字符串,计算其实际字符个数并打印输出,即不使用字符串处理函数strlen()编程实现strlen()的功能。
**输入格式要求:gets()
**提示信息:“Please enter a string:”
**输出格式要求:“The length of the string is: %u\n”
程序的运行示例如下:
Please enter a string:Hello China
The length of the string is: 11
#include<stdio.h>
int main(void)
{
char s[100];
int count = 0;
int i;
printf("Please enter a string:");
gets(s);
for (i = 0; s[i] != '\0'; i++)
count++;
printf("The length of the string is: %u\n", count);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)