#include<stdio.h>
int GetLen(char * str);
void main()
{
char * str;
int count=0;
printf("请输入需计算长度字符串:\n");
scanf("%s",str);
count=GetLen(str);
printf("%d\n",count);
}
int GetLen(char * str)
{
int count=0;
for(str;(*str)!='\0';str++)count+=1;
return count;
}
运行环境是 Turbo C
我也是初学,互相学习哈。
温馨提示:答案为网友推荐,仅供参考