How do I work with dynamic multi-dimensional arrays in C?

前端 未结 9 1785
庸人自扰
庸人自扰 2020-11-22 05:14

Does someone know how I can use dynamically allocated multi-dimensional arrays using C? Is that possible?

9条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 06:03

    // use new instead of malloc as using malloc leads to memory leaks `enter code here

        int **adj_list = new int*[rowsize];       
        for(int i = 0; i < rowsize; ++i)    
        {
    
            adj_list[i] = new int[colsize];
    
        }
    

提交回复
热议问题