小编use*_*144的帖子

灵活数组成员的无效使用

我在编程时遇到了问题。

struct skills {
    int SnCrypt;
    char* Soutput;
    int Soptind;
    int Sdecrypt;
    int Sargc;
    char* Spassword;
    char *const Sargv[];
};

struct skills* initSkills(int nCrypt, char* password, char *const argv[], char* output, int optind, int decrypt, int argc) {
    struct skills* skill;
    skill->SnCrypt = nCrypt;
    skill->Spassword = password;
    skill->Sargv = argv;
    skill->Soutput = output;
    skill->Soptind = optind;
    skill->Sdecrypt = decrypt;
    skill->Sargc = argc;

    return skill;
}
Run Code Online (Sandbox Code Playgroud)

和 gcc 告诉我

灵活数组成员的无效使用

为线skill->Sargv = argv;

我不明白我怎么能指向char *const argv[]另一个指针所指向的值?我知道我肯定必须malloc …

c++

3
推荐指数
1
解决办法
7335
查看次数

标签 统计

c++ ×1