100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > c语言定义函数后引用 求助 函数在其他函数中使用时要先声明后调用 这个没声明就用了...

c语言定义函数后引用 求助 函数在其他函数中使用时要先声明后调用 这个没声明就用了...

时间:2023-08-24 07:00:06

相关推荐

c语言定义函数后引用 求助 函数在其他函数中使用时要先声明后调用 这个没声明就用了...

该楼层疑似违规已被系统折叠隐藏此楼查看此楼

如题,程序如下:

#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:%ld\nscore:%5.1f\n",pt->num,pt->score);

return 0;

}

函数调用,涉及到动态链表就不用声明了么??

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。