探讨结构体声明是放在main函数里面,还是外面呢?
#include <stdio.h>struct student
{
long num;
float score;
struct student *next;
};
void main()
{
struct student a,b,c,*head;
a.num = 10101;
a.score = 89.5;
b.num = 10103;
b.score = 90;
c.num = 10107;
c.score = 85;
head = &a;
a.next = &b;
b.next = &c;
c.next = NULL;
do
{
printf("%ld %5.1f\n",(*head).num,(*head).score);
head = (*head).next;
}while(head);
} 一般情况下结构体定义,头文件包含,函数声明,宏定义,都是放在main前面 bin554385863 发表于 2019-11-5 16:45
一般情况下结构体定义,头文件包含,函数声明,宏定义,都是放在main前面
好的,谢谢您!
页:
[1]