0

我怎么能这样做:

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;
4

2 回答 2

1

不,可以在声明数组时初始化数组,否则不能。

于 2010-02-16T09:52:37.440 回答
1

你不能在 C++ 中那样实例化。

如果您使用可以动态创建的匿名类型,那么在 C# 中是可能的(某种程度上)。

于 2010-02-16T09:52:58.360 回答