我怎么能做到这一点:
char sXSongs[20][30] = {"Song 1", "Song 2 (w/Blur)", "The End (It's Not Here Yet)"};
addAlbum(&list, "The Beatles", "Some Famous CD", 1960, sXSongs);
但这不是:
addAlbum(&list, "The Beatles", "Some Famous CD", 1960, {"Song 1", "Song 2 (w/Blur)", "The End (It's Not Here Yet)"});
是否可以在函数调用中初始化cstrings数组?
以下是一些其他信息:
album* list = NULL;
typedef struct album {
char performer[20];
char CDtitle[50];
int year;
char songs[20][30];
struct album* prev;
struct album* next;
} album;
最佳答案
否。可以在声明数组时初始化数组,否则不能初始化。
关于c - 在函数调用中初始化cstring数组,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2271874/