Floating pointer Error in a code

  • Follow


Dear friends,

Please consider the following C program.


#include<stdio.h>

struct employee
{
   int id;
   float sal;
};

main()
{
   struct employee emp[5];
   int i=1;
   scanf("%f",&emp[i].sal);

   return 0;
}



When I run the follwoing C program on TurboC++ Version 3.0 on Windows
it shows the error,

       scanf: floating point format not linked.
       Abnormal program termination

Please tell me why this happens.

The same code shows no error when I replace the variable 'i' in the scanf statment
with an interger, like

scanf("%f",&emp[1].sal);

Please tell me what is wrong with the code.


Lal
0
Reply sreelalpp (11) 8/12/2004 3:27:25 PM

On Thu, 12 Aug 2004, sreelal wrote:

> Dear friends,
>
> Please consider the following C program.
>
>
> #include<stdio.h>
>
> struct employee
> {
>    int id;
>    float sal;
> };
>
> main()
> {
>    struct employee emp[5];
>    int i=1;
>    scanf("%f",&emp[i].sal);
>
>    return 0;
> }
>
>
>
> When I run the follwoing C program on TurboC++ Version 3.0 on Windows
> it shows the error,
>
>        scanf: floating point format not linked.
>        Abnormal program termination
>
> Please tell me why this happens.

Your compiler does not support floating point math by default. You need to
read your compiler documentation to understand how to enable this.

> The same code shows no error when I replace the variable 'i' in the scanf statment
> with an interger, like
>
> scanf("%f",&emp[1].sal);
>
> Please tell me what is wrong with the code.
>
>
> Lal
>

-- 
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to vice.president@whitehouse.gov
0
Reply darrell14 (26) 8/12/2004 4:07:41 PM


sreelal wrote:
> Please consider the following C program.
[snipp]

>    scanf("%f",&some_float);

[ I hope that this simple line will already trigger the error and that you
just neglected to make the smallest possible example from it. ]

> When I run the follwoing C program on TurboC++ Version 3.0 on Windows
> it shows the error,
> 
>        scanf: floating point format not linked.
>        Abnormal program termination

Question: did you run the program or did you compile it to produce that
output? Anyhow, it looks like support for floatingpoint operations was not
compiled in, which makes sense when compiling for machines without an FPU,
e.g. prehistoric personal computers.

> Please tell me why this happens.

Your program is (mostly) fine, so the issue is rather with your compiler.
Take the issue to a newsgroup where that compiler is on topic. 
Maybe even better, switch to a modern compiler, DevC++(no, it's not just
for C++) comes for free and with a modern compiler.

Uli

0
Reply doomster121 (274) 8/12/2004 4:15:48 PM

sreelal wrote on 12/08/04 :
>        scanf: floating point format not linked.
>        Abnormal program termination
>
> Please tell me what is wrong with the code.

Nothing. It's a well known issue of BOrland C compilers. Add this at 
the top of the source file:

#ifdef __BORLANDC__
/* The pesky "floating point format not linked" killer hack : */
extern unsigned _floatconvert;
#pragma extref _floatconvert
#endif

-- 
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

"C is a sharp tool"

0
Reply emdel (952) 8/12/2004 4:30:57 PM

hi,
i am getting an error like
[test.o] Error 255 
please help me to find out the problem..

thanks in advance,
Subashini

0
Reply subashinicv (2) 8/17/2004 1:25:12 PM

subashini <subashinicv@ctd.hcltech.com> scribbled the following:
> hi,
> i am getting an error like
> [test.o] Error 255 
> please help me to find out the problem..

Not knowing which compiler you are using, you might as well say "I'm
getting some weird error" and expect us to be able to fix your code.
Error 255 might mean anything from a missing semicolon to an internal
bug in the compiler. We have as much chance of knowing which specific
error it is as we have of knowing the contents of your wallet.

-- 
/-- Joona Palaste (palaste@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"The trouble with the French is they don't have a word for entrepreneur."
   - George Bush
0
Reply palaste (2323) 8/17/2004 1:34:10 PM

hi,
	i am trying to compile my C code in montavista development environment. &
getting the error as 
"*** [test.o] Error 255"

& i am getting no other compilation error.

Please help me to solve the error.

Thanks in advance,
Subashini

0
Reply subashinicv (2) 8/18/2004 5:42:58 AM

6 Replies
48 Views

(page loaded in 0.091 seconds)

Similiar Articles:













7/6/2012 7:55:20 AM


Reply: