【发布时间】:2026-02-21 22:15:01
【问题描述】:
您好,我在为属于第二个结构的结构分配内存时需要帮助,并且第二个结构具有双指针作为减速。
struct ant{
int stu;
int clas;
char *name;
};
struct cat{
int a;
int b;
struct ant *c;
};
int main()
{
struct cat **sample;
struct ant *info;
info = calloc(1, sizeof(*info));
<here i had allocated memory for **info** which is of type **ant**>
<now i need to assig this **info** to the pointer which is there in **cat** structure>
<how we can achive this> ?
}
【问题讨论】:
-
你想和几只猫和蚂蚁一起玩?
-
实际上是什么意思
-
我怎么知道蚂蚁在初始化一只猫时应该如何分配内存?
-
蚂蚁应该是一个
标签: c data-structures structure dynamic-memory-allocation