这是我的另一个问题的延续.
请考虑以下代码:
char *hi = "hello";
char *array1[3] =
{
hi,
"world",
"there."
};
Run Code Online (Sandbox Code Playgroud)
它没有编译到我的意外(显然我不知道C语法以及我认为)并生成以下错误:
error: initializer element is not constant
Run Code Online (Sandbox Code Playgroud)
如果我将char*更改为char [],则编译正常:
char hi[] = "hello";
char *array1[3] =
{
hi,
"world",
"there."
};
Run Code Online (Sandbox Code Playgroud)
有人可以向我解释原因吗?