且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

GCC说"默认情况下启用]从兼容的指针类型赋值

更新时间:2022-01-29 01:04:03

createArray 函数声明和一个错误的工具。你需要字符数组的指针,它的类型(的char ** ),所以创建并返回这样一个数组:

Your createArray functions is declared and implement with a mistake. You need an array of char pointers, which is of type (char **), so create and return such an array:

char** createArray(int count) {
    char** a;
    a = malloc(sizeof(char*) * count);
    if (a == 0) {
        fprintf(stderr, "memory allocation failed\n");
        exit(1);
    }

    return a;
}