Coding problem using a 2-d array of structs inside another struct in C

前端 未结 5 776
醉酒成梦
醉酒成梦 2021-02-06 10:58

I am working with a 2-dimensional array of structs which is a part of another struct. It\'s not something I\'ve done a lot with so I\'m having a problem. This function ends up f

5条回答
  •  死守一世寂寞
    2021-02-06 11:46

    it looks like you are trying to copy array by assignment. You cannot use simple assignment operator to do that, you have to use some function to copy things, for example memcpy.

    *thisImage.arr = *imageArr;
    thisimage.arr[0] = imagearr[0];
    

    The above statements are doing the same thing. However this is not most likely what causes the memory corruption

    since you are working with two dimensional arrays, do make sure you initialize them correctly. Looking at the code, should not even compile: the array is declared as one-dimensional in your image structure but you refer to as two-dimensional?

提交回复
热议问题