编一程序,求出从键盘输入的字符串的长度。
Status Length()
{
int i;
char str[81];
int cns = 0;
char *p;
for(i=0;i<80;i++)
{
str[i]=getchar();
if(str[i]=='\n') break;
}
str[i]='\0';
p=str;
while(*p)
{
*p++;
cns++;
}
return cns;
}
int main()
{
int length = Length();
printf("%d",length);
system("pause");
}