已有定义如下: struct node {int data; struct node *next;

大学专科 已帮助: 时间:2023-08-15 07:07:18

已有定义如下: struct node {int data; struct node *next; } *P; 以下语句调用malloc函数,使指针p指向一个具有struct node类型的动态存储空间。 请填空。 p=(struct node *)malloc 【 】;
请帮忙给出正确答案和分析,谢谢!

难度:⭐⭐⭐

题库:大学专科,电子信息,计算机类

标签:已有,指针,正确答案

参考解答

用户头像

487***302

2023-08-15 07:07:18

正确答案:sizeof(struct node)或4
C标准规定malloc()函数返回值的类型为void*,函数的调用形式为:malloc(size)。要求size的类型为unsignedint,所以该空格处应该填sizeof(structnode)或4。

上一篇 以下程序运行后的输出结果是【 】。 fun(int x) { if(x/2>0)fun(x/2);

下一篇 以下程序运行后的输出结果是【 】。 main() { int i n[]=10 0 0 0 0};

相似问题