题目内容:利用指针编写程序,统计字符串的长度。(不要使用求字符串长度函数)
输入格式:
gets()
输出格式:
"Length of the string is %d\n"
输入样例:
I like programming.
输出样例:
Length of the string is 19
时间限制:500ms内存限制:32000kb
#include<stdio.h>
int main()
{
char str1[50], str2[50];
char *s=str1;
int i=0;
gets(str1);
while(*s!='\0'){
*s++;
i++;
}
printf("Length of the string is %d\n",i);
return 0;
}