#include
int main(void)
{
char str1[];
//这里用char *str1的话,不会报错,但是不会输出键入的字符串
//char *str1;
fgets(str1,5,stdin);
puts(str1);
return 0;
}
求原因
#include
int main(void)
{
char str1[];
//这里用char *str1的话,不会报错,但是不会输出键入的字符串
//char *str1;
fgets(str1,5,stdin);
puts(str1);
return 0;
}
求原因
指针若是指向数组首地址,效果一样的。
若是没有进行初始化,指针的地址是不确定的(编译为调试版本时,地址为0xcccccccc),不知道指向哪里,程序的行为是不确定的。