Recently, I was writing a struct-linked list.ProgramWhen an error message such as floating point formats not linked occurs, you can check carefully to check whether there are any errors. The abbreviated procedure is as follows:
# Include < Stdio. h >
# Include < Stdlib. h >
# Include < Conio. h >
Struct Student
{
Int Num;
Float Score;
Struct Student * Next;
};
Void Main ()
{
Struct Student * P;
Clrscr ();
P = ( Struct Student * ) Malloc ( Sizeof ( Struct Student ));
Scanf ( " % D, % F " , & P -> Num, & P -> Score );
Printf ( " % D, % F " , P -> Num, P -> Score );
Free (P );
}
There is no problem with the program. After compilation and running, it will appear when the input is.
Scanf: floating point formats not linked
Such errors are depressing.
Later, I checked some information online to know that this is Borland run-time error. The details are as follows:
Why did my program bomb at run time with 'floating point formats not linked' or 'floating point not loaded '?
--------------------------------------------------------------------------------
Date: 5 Feb 2002 22:03:03-0400
These messages look similar but have very different causes.
"Floating point not loaded" is Microsoft C's run-time message when
Code requires a numeric coprocessor but your computer doesn't have one
Installed. If the program is yours, relink it using the xlibce or xlibca
Library (where X is the memory model ).
"Floating point formats not linked" is a Borland run-time error (Borland
C or C ++, Turbo C or C ++). Borland's compilers try to be smart and not
Link in the floating-point (f-p) library unless you need it. Alas, they
All get the demo-wrong. One common case is where you don't call any
F-P functions, but you have % f or other f-P formats in scanf () or
Printf () CILS. The cure is to call an F-P function, or at least force
One to be present in the link.
To do that, define this function somewhere in a source file but don't
Call it:
Static void forcefloat (float * P)
{
Float F = * P;
Forcefloat (& F );
}
It doesn' t have to be in the module with the main program, as long
It's in a module that will be inserted in the link.
If you have Borland C ++ 3.0, the README file except ents a slightly less
Uugly work-around. insert these statements in your program:
Extern unsigned _ floatconvert;
# Pragma extref _ floatconvert
Solution:
You only need to add any red part to the program to run properly.
However, the principle is still not clear.
Why?