Floating pointer Error in a code

S

sreelal

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.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
 
D

Does It Matter

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.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
 
U

Ulrich Eckhardt

sreelal said:
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
 
E

Emmanuel Delahaye

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
 
S

subashini

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

thanks in advance,
Subashini
 
J

Joona I Palaste

subashini said:
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.
 
S

subashini

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top