77问答网
所有问题
struct student* p = malloc(sizeof(struct student)); struct student* p ;
它们 的区别,尽量详细
举报该问题
推荐答案 2010-10-25
struct student* p = malloc(sizeof(struct student));
后面的malloc()函数分配了一块可以保存一个student结构体变量的空间,并把这块空间的地址返回给了p,这样,p指针就指向了一块空间,可以通过p变量对这块空间进行读写操作。
struct student* p ;
这一行只是定义一个指针变量p,它还没有指向任何可操作的空间。
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://77.wendadaohang.com/zd/Gq8Yp8Gpq.html
其他回答
第1个回答 2010-10-25
前者分配了初始空间 后者没有
第2个回答 2010-10-26
这个也问。回去翻书。
相似回答
...
student *
)
malloc(sizeof(struct
student));
是不是等效的???_百度...
答:
而这里也同样的,
struct
student
是一种类型,而p没有指向这个类型的某个对象,一般定义这条语句初始化都是指向null,也就是空,而第二句的意思是,调用
malloc函数
,返回为动态开辟内存区域的首地址,也就是指针已经指向了某块内存区域 即 这两句语句是不等价的 ...
...
student *
)
malloc(sizeof(struct
student));
这个语句有什么作用...
答:
新建一个student数据结构的对象,为其分配student结构所占用的内存空间。
sizeof(struct
student)
为求该对象在内存中占用多少内存空间,让后用
malloc函数
分配同样大小的空间。将指针p1,p2指向该对象,即新分配出的空间。
解释一下这段c代码
答:
struct
student *
p1=NULL,*p2=NULL; 声明两个学生结构。p1=(struct student *)
malloc(sizeof(struct
student));
给p1结构分配单元 下面输入
学生
名,scanf("%s",p1->name);学号,scanf("%s",p1->num);三门成绩 scanf("%d",p1->score[i]);下一个学生指针为"没有”:p1->next=NULL
;struc
...
p=(struct
student*
)
malloc(sizeof(struct
student))
答:
动态声明了一个
student结构体
的内存空间, 并将这块空间的指针保存给p变量
帮小弟做一道C语言编程作业题,谢谢大家了~(要详细的程序命令啊)_百度...
答:
float score;};main(){ int i,N,count=0;float max
;struct
student *p;
printf("please input students'number:N=");scanf("%d",&N);p=(struct
student*
)
malloc(
N*
sizeof(struct
student));
printf("\nplease input students' score:\n");printf("NO.\tscore\n");for(i=0;i<N;i++...
(struct
Student*
)
malloc(sizeof(struct
Student))
是什么意思
答:
分配大小为
sizeof(struct
Student)
的内存空间,同时将内存地址指正转换成struct Student 类型,该用法一般是为
结构体
指针分配内存空间。
编写代码实现如下功能:定义大小为3的
Student
类型指针数组用于存储
学生
的...
答:
struct Date birthday;};int main(){ int i;float avg = 0.0
;struct
Student *p
Stu[3];for(i=0;i<3;i++){ pStu[i] = (struct
Student*
)
malloc(sizeof(struct
Student));
scanf("%s",pStu[i]->name);scanf("%d",&pStu[i]->birthday.year);scanf("%d",&pStu[i]->birthday....
大家正在搜
struct student
sizeof struct
malloc sizeof
malloc与sizeof
mallocsizeof用法
malloc函数sizeof
数据结构mallocsizeof
sizeof和strlen的区别
sizeofstruct
相关问题
struct student *p;和p=(struct s...
*pStudent=(struct student*)mal...
pEnd=pNew=(struct Student*)mal...
(struct Student*)malloc(sizeof...
p1 = p2 = (struct student *)ma...
c语言 pEnd=pNew=(struct Student*...
C语言 链表中malloc 用处: 比如head=(stru...