The program as follows can run good under C++ envirement.Under C,the output is:"scanf:floating point formats not linked. Abnormal program termination."
I don't know where the mistake is.
#include<stdio.h>
typedef struct student
{float score;
}student;
main()
{student *a;
a=(student*)malloc(sizeof(student));
scanf("%f",&a->score);
printf("The score is:%f\n",a->score);
}
But after I have changed some of this program,it works.The other one goes here:
#include<stdio.h>
typedef struct student
{float score;
}student;
main()
{student b;
scanf("%f",&b.score);
printf("The score is:%f\n",b.score);
}
It works without any problems.Why?What's the differece between them?
I don't know where the mistake is.
#include<stdio.h>
typedef struct student
{float score;
}student;
main()
{student *a;
a=(student*)malloc(sizeof(student));
scanf("%f",&a->score);
printf("The score is:%f\n",a->score);
}
But after I have changed some of this program,it works.The other one goes here:
#include<stdio.h>
typedef struct student
{float score;
}student;
main()
{student b;
scanf("%f",&b.score);
printf("The score is:%f\n",b.score);
}
It works without any problems.Why?What's the differece between them?