Is it possible to allocate array inside function and return it using reference?

后端 未结 3 1232
离开以前
离开以前 2020-12-02 01:14

I\'ve tried using a tripple pointer, but it keeps failing. Code:

#include 
#include 

int set(int *** list) {
  int count, i;
         


        
3条回答
  •  时光说笑
    2020-12-02 01:36

    you have an array of integer arrays. Let's look at your set function closely:

    for (i = 0; i < count;i++ ) {
        (**list)[count] = 123;
    }
    

    As you can see you are treating every array object like an integer value. That should be a nested loop:

    for (i to n)
        // allocate each array
        for (k to m)
            // assign value for each value of array
    

提交回复
热议问题