数据结构的例题发现有几个变量名有错(翻译时翻错的)
----------------解决方案--------------------------------------------------------
C Run-Time Error R6002
floating-point support not loaded
The program needs the floating-point library, but the library was not linked to the program.
One of the following may have occurred:
The program was compiled or linked with an option (such as /FPi87) that required a coprocessor, but the program was run on a machine that did not have a coprocessor installed.
A format string for a printf or scanf function contained a floating-point format specification, and the program did not contain any floating-point values or variables.
The compiler minimizes a program's size by loading floating-point support only when necessary. The compiler cannot detect floating-point format specifications in format strings, so it does not load the necessary floating-point routines.
Use a floating-point argument to correspond to the floating-point format specification, or perform a floating-point assignment elsewhere in the program. This causes floating-point support to be loaded.
In a mixed-language program, a C library was specified before a FORTRAN library when the program was linked. Relink and specify the C library last.
----------------解决方案--------------------------------------------------------
#include "stdio.h"
#include "malloc.h"
#define NULL 0
#define LEN sizeof(struct student)
struct student
{ int num;
float score;
struct student *next;
};
int n;
struct student *creat() //把creat()中的void去掉,如左
{ struct student *head,*p1,*p2;
n=0;
p1=p2=(struct student *)malloc(LEN);
printf("input p1.num,p1.score");
scanf("%d,%f",&p1->num,&p1->score);
head=NULL;
while(p1->num!=0)
{n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
scanf("%d,%f",&p1->num,&p1->score);
}
p2->next=NULL;
return(head);
}
main() //把main()函数体改为如左所示
{struct strdent *head;
head=creat();
}
----------------解决方案--------------------------------------------------------
《C Primer Plus(第五版)中文版》
这里有电子版:
http://www.verycd.com/topics/71660/
也可以到较大型书店买,只是比较金一点,定价60元。
----------------解决方案--------------------------------------------------------
怎么还没高手解释啊,是老谭的书,只介绍了怎么创建函数,没把函数运用到main中,所以不会,我的哪错了,我不要程序,只是想知道我的哪错了
----------------解决方案--------------------------------------------------------
scanf("%d,%f",&p1->num,&p1->score);出错
我看了一下,是&p1->score有问题,原因我也不太清楚,我的办法是前面定义float f;
再scanf("%d,%f",&p1->num,&f);
p1->score=f;
----------------解决方案--------------------------------------------------------