【发布时间】:2021-11-26 07:12:24
【问题描述】:
我有一个结构:
typedef struct{
int age;
int height
}Human;
我用该结构创建了一个多维数组:
Human human_table[3][2]={
{{1,1},{1,1}},
{{1,1},{1,1}},
{{1,1},{1,1}},
};
我创建了一个指向表的指针
typedef struct human_table *humanPointer;
现在的问题是,如何创建一个函数来修改上面的表格?
我目前有这个:
void Modify_Human_age(humanPointer human_table, int x, int y, int New_Age)
{
human_table[x][y]->age=New_Age;
}
但我收到一个错误,正在寻求有关如何修复 Modify_Human_age 函数的帮助。
谢谢
【问题讨论】:
-
你的错误是什么?
-
无效使用未定义类型“struct human_table”并取消引用指向不完整类型“struct human_table”的指针
-
struct human_table是一个类型的名称。你永远不会定义这种类型。您定义了一个名为human_table的变量,但它与struct human_table无关。将所有提及的struct human_table替换为Human。 -
您也错误地使用了您的可能指向表的指针。您最好使用指向 单行 的指针。