字符数组为什么不可以先定义,然后再初始化呢?谢谢各位大侠
#include <string.h>#include <stdio.h>
int main()
{
char ch[20];
ch[20]={"hello world!"};
puts(ch);
return 0;
}
程序代码:--------------------Configuration: test61 - Win32 Debug--------------------
Compiling...
test61.cpp
test.cpp
f:\test.cpp(8) : error C2059: syntax error : '{'
f:\test.cpp(8) : error C2143: syntax error : missing ';' before '{'
f:\test.cpp(8) : error C2143: syntax error : missing ';' before '}'
执行 cl.exe 时出错.
test61.exe - 1 error(s), 0 warning(s)编译时提示如下的错误:









