Array of structs replacing values over itself

后端 未结 3 1351
有刺的猬
有刺的猬 2020-11-30 15:25

Ok so I have the below code and I am just pulling various things from a file and inputing them in an array of structs, it \"seemingly\" works initially, BUT when I go to pri

3条回答
  •  天涯浪人
    2020-11-30 16:10

    The error is here.

    d[counter].name=name;
    

    replace with:

    d[counter].name = strdup(name); /*don't forget to free this memory.*/
    

    the issue for the courses is the same.

提交回复
热议问题