菜鸟求助,请各位大小虾帮忙看一下哪里出问题了~
原文,这是一个建立链表的小程序:出了很多警告和一个错误,麻烦各位大大办忙看看并且解释一下存在的问题,感激不尽!#include<stdio.h>
#include<malloc.h>
#define NULL 0;
struct student
{
int age;
char name[20];
float score;
struct student *next
};
void main()
{
int i;
struct student *p,*head,*p1;
for(i=0;i<3;i++)
{
if(i=0)head=p1=p=(struct student *)malloc(sizeof(struct student));
else
{
p=(struct student *)malloc(sizeof(struct student));
if(i=1)head->next=p1=p;
if(i=2){p1->next=p;p->next=NULL;}
}
printf("please input the student information:\n");
scanf("%20s,%3d,%5f",&p->name,&p->age,&p->score);
p=head;
};
do
{printf("%s's age is %d, score is%f",p->name,p->age,p->score);
p=p->next;
}while(p!=NULL);
}
提示的错误信息:
gcc -Wall -c "node.c" (在目录/home/gmtianxia/桌面/编程练习中)
编译失败
node.c:3:1: warning: "NULL" redefined
In file included from /usr/include/malloc.h:25,
from node.c:2:
/usr/lib/gcc/i486-linux-gnu/4.4.1/include/stddef.h:400:1: warning: this is the location of the previous definition
node.c:10: warning: no semicolon at end of struct or union
node.c:11: warning: return type of ‘main’ is not ‘int’
node.c: In function ‘main’:
node.c:17: warning: suggest parentheses around assignment used as truth value
node.c:21: warning: suggest parentheses around assignment used as truth value
node.c:22: warning: suggest parentheses around assignment used as truth value
node.c:25: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[20]’
node.c:33: error: expected ‘)’ before ‘;’ token