为什么结构数组不需要大括号初始化?
这段代码:
#include <stdio.h>
struct
{
int i;
const char* str;
} ar[] = {
1,"asd", //should be {1, "asd"},
2, "qwe", //should be {2, "qwe"},
3, "poi" //should be {3,"poi"}
};
int main()
{
printf("%sn", ar[2].str);
}
工作得很好,即使数组的每个元素都ar应该用大括号括起来(至少我希望如此)。为什么这是可能的?