到目前为止,我有以下代码,我很确定我可以用多个语句进行显式初始化,但我想学习如何用一个语句来做。
#include <stdio.h>
#include <stdlib.h>
#define LUNCHES 5
int main(void)
{
struct Food
{
char *n; /* “n” attribute of food */
int w, c; /* “w” and “c” attributes of food */
}
lunch[LUNCHES],
lunch[0] = {"apple pie", 4, 100},
lunch[1] = {"salsa", 2, 80};
}
我认为以下内容会起作用,但这是另一种说法。
int main(void)
{
struct Food
{
char *n; /* “n” attribute of food */
int w, c; /* “w” and “c” attributes of food */
}
lunch[LUNCHES];
lunch[0] = {"apple pie", 4, 100};
lunch[1] = {"salsa", 2, 80};