请教大家,为什么把红色的变量改为inputstr[20]就OK,而下面的程序却编译不过?谢谢``
#include<stdio.h>
int
Str_len(char *str)
{
int num=0;
char *p;
p=str;
while((*p)!='\0')
{
p++;
num++;
}
return num;
}
/*----------------------------------------------------------*/
int
main(void)
{
char *inputstr;
int i;
printf("Please input the string:\n");
scanf("%s",inputstr);
printf("This string has %d sizes.\n",Str_len(inputstr));
return 0;
}