大学生初学,定义二维数组的问题求指点,预计定义一个可自动决定大小的数组,并且每个元素含有多个变量

#include

typedef int Status;
typedef struct Node
{

Status var1;
Status var2;

};

int main()
{
int i,j,s=0;//i表示行。j表示咧。s为总路程,初始化为0
int Num_Nodes;
//定义二维数组
Node** a;//二级指针

a = (Node** )malloc ((sizeof (Node*))*Num_Nodes);

for (i=0; i<Num_Nodes; ++i)
{
    a[i] = (Node*)malloc ((sizeof (Node))*Num_Nodes);
}

}

现需要知道数组大小。可以动态获取大小,然后malloc来动态分配。

看你程序是申请:

     Node a[Num_Nodes][Num_Nodes];

但是Num_nodes变量未初始化。

看你程序是申请:

     Node a[Num_Nodes][Num_Nodes];

但是Num_nodes变量未初始化。