概述
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
如题,程序如下:
#include
#include //malloc,calloc,free,realloc头文件
#define LEN sizeof(struct Student)
struct Student
{long num;
float score;
struct Student *next;
};
int n; //到这里都是一些初始定义
struct Student *creat(void) //这里开始定义了一个函数creat
{
struct Student *head,*p1,*p2;
n=0;
p1=p2=(struct Student*)malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->score);
head=NULL;
while(p1->num!=0)
{
n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct Student*)malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->score);
}
p2->next=NULL;
return (head);
} //到这里creat函数定义部分结束一般函数定义都写后面这个写前面了,区别?
int main() //这里开始main函数
{
struct Student *pt;
pt=creat(); //不懂在这点,没声明,直接就调用了??编译运行没错误
printf("nnum:%ldnscore:%5.1fn",pt->num,pt->score);
return 0;
}
函数调用,涉及到动态链表就不用声明了么??
最后
以上就是无辜大门为你收集整理的c语言函数必须先定义后使用吗,求助,函数在其他函数中使用时要先声明后调用,这个没声明就用了...的全部内容,希望文章能够帮你解决c语言函数必须先定义后使用吗,求助,函数在其他函数中使用时要先声明后调用,这个没声明就用了...所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复