473,320 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Floating pointer Error in a code

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
Nov 14 '05 #1
6 2203
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

Nov 14 '05 #2
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 vi************@whitehouse.gov
Nov 14 '05 #3
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"

Nov 14 '05 #4
hi,
i am getting an error like
[test.o] Error 255
please help me to find out the problem..

thanks in advance,
Subashini

Nov 14 '05 #5
subashini <su*********@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 (pa*****@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
Nov 14 '05 #6
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

Nov 14 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dave | last post by:
Hi folks, I am trying to develop a routine that will handle sphere-sphere and sphere-triangle collisions and interactions. My aim is to develop a quake style collision engine where a player can...
687
by: cody | last post by:
no this is no trollposting and please don't get it wrong but iam very curious why people still use C instead of other languages especially C++. i heard people say C++ is slower than C but i can't...
4
by: jacob navia | last post by:
Hi people I continue to work in the tutorial for lcc-win32, and started to try to explain the floating point flags. Here is the relevant part of the tutorial. Since it is a difficult part, I...
4
by: rz0 | last post by:
Hi all, This is a question about both C89 and C99 and is based on my partial reading of the standard drafts (one from before C89 but mainly N1124). If appropriate, please give a...
8
by: vendredi5h | last post by:
Hello all, I'd like to split a 64-bits word (hold as a floating point number) into two 32-bits words (hold as integers). Bitwise operators are working on Integers, not on floating point. ...
7
by: thisismyidentity | last post by:
Hi all, I am trying to predict the behaviour of floating point load and store operations on integer locations. I ve written a small piece of code having some inline assembly code which I am...
4
by: alex | last post by:
hi friends ... i am facing a problem while detecting floating point operations in my project, please help me. i want to find out the places in my C/C++ project where i am doing floating...
8
by: myfem.analyzer | last post by:
Hi, I saw a line of codes in the "Fast Inverse Square Root" like this: Float InvSqrt(float x) { ....... int i = *(int *) &x; //get bits for floating value ..... x = * (float *) &i; ...
1
Parul Bagadia
by: Parul Bagadia | last post by:
I just wrote a code for myself to clear certain things........... When i made this program to execute in turbo c++ it didnt..... it showed following error. I have pasted the output after code is...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.