Passing multi-dimensional arrays in C

前端 未结 5 763
無奈伤痛
無奈伤痛 2021-01-15 02:45

I am currently trying to learn C and I have come to a problem that I\'ve been unable to solve.

Consider:

#include 
#include 

        
5条回答
  •  深忆病人
    2021-01-15 03:16

    See PolyThinker's comment which is absolutely spot on.

    In addition to the way you pass the array, you should check a few other issues:

    1. Perhaps you should assign something to array_size in make(...)?
    2. strdup(char*) allocates memory, the malloc for array[i] is not necessary.
    3. You should free all the memory you allocate after you don't need it anymore.

提交回复
热议问题