scanf:floating point flrmats not linked...
为什么会在输入第二个数据的时候就出现scanf:floating point formats not linked Abnormal program termination
这是我的程序,那位大侠能帮小弟解决一下,谢谢了;
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
struct student
{
int num;
float a;
int sex;
struct student *next;
};
void s_scanf( struct student *p )
{
scanf("%d", &p->num);
fflush( stdin );
scanf("%f", &p->a);
fflush( stdin );
scanf("%d", &p->sex);
fflush( stdin );
}
struct student *b( void )
{
struct student *head, *p, *p1;
int n=1;
p = (struct student *)malloc( sizeof(struct student) );
p->num = 1;
while( p->num )
{
if( 1==n++ )
head = p;
p1 = p;
s_scanf( p );
p = (struct student *)malloc( sizeof(struct student) );
p1->next = p;
}
p->next = NULL;
return( head );
}
void print( struct student *head )
{
struct student *p;
p = head;
while( p->num )
{
printf("%d\t%f\t%d\n", p->num, p->a, p->sex);
p = p->next;
}
}
int main( void )
{
struct student *head;
head = b();
print( head );
return 0;
}