小编suk*_*ity的帖子

没有分配重新分配的指针

我试图动态分配一个结构数组但是每当我运行程序时我都会得到:a.out(6487,0x7fff7ecb8300)malloc:*对象0x7fff6f670000的错误:没有分配重新分配的指针*在malloc_error_break中设置一个断点调试

struct node {
    char course[25];
    char category[20];
    char prereq[50];
    char notes[50];
};



int main(int argc, char* argv[])
{
    FILE *fp;
    char *filename = argv[1];
    char *token;

    char buffer[100];
    char *del = ",\n";
    int num = 5, i = 0, j =0, count = 0;
    struct node *d = malloc(num * sizeof(struct node));
    char** complete = malloc(num * sizeof(char*));
    printf("%s\n", filename);


    if( (fp = fopen(filename, "r")) == NULL )
    {
        printf("unable to open %s\n", filename);
        exit(1);
    }
    while(fgets(buffer, …
Run Code Online (Sandbox Code Playgroud)

c malloc realloc

0
推荐指数
1
解决办法
2176
查看次数

标签 统计

c ×1

malloc ×1

realloc ×1