有问题啊~
有两个问题,望高手解答.#include <stdio.h>
#define M 0
#define F 1
#define OK 1
#define EOR 0
#define NULL 0
struct stu
{
int num[5];
char name[10];
char sex;
struct stu *next;
}
*pro(int n)
{
int a;
struct stu *head,*f,*s;
for(a=0;a<n;a++)
{
f=(struct stu *)malloc(sizeof(struct stu));
printf("\nnum:");
scanf("%d",&f->num); /*为什么输出总是三千多?*/
printf("name:");
scanf("%s",&f->name);
printf("sex(M or F):");
scanf("%s",&f->sex); /*为什么"s"改成"c"就不行了?*/
if(a==0)head=s=f;
else s->next=f;
s=f,f->next=NULL;
}
return(head);
}
void outp(struct stu *head)
{
struct stu *f=head;
for(;f!=NULL;f=f->next)
printf("\nnum:%d name:%s sex:%c",f->num,f->name,f->sex);
}
main()
{
struct stu *head;
int n;
printf("How many data do you want to input?\n");
scanf("%d",&n);
head=pro(n);
outp(head);
getch();
}