Error Analysis: floating point formats not linked

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.