Problem with Turbo C++
brian_helterline
brianh at hpcvia.CV.HP.COM
Thu Oct 4 01:22:37 AEST 1990
>I hope someone can help me with this one!
> After much procrastinating I decided to attempt to learn C after many
>years as a strictly FORTRAN programmer. I got started O.K. writing the
>standard "Hello World" program and then some very simple file I/O code.
>Now the trouble starts! What I want to do is read in a vector, actually
>the variable I use is a matrix but I only want to read one column from the
>file which has a format like:
>2
>1.00
>2.00
>where two is the number of elements in the file. To accomplish this I
>used this piece of code:
>for( nr=1; nr <= Anr; nr++)
>{
> fscanf( inpfile, "%f\n", &A[nr][1] );
>}
>Now everything compiles fine but when I run it I get the following error:
> scanf : floating point formats not linked
>Abnormal program terminaion.
>Anyone know what this means? I can run the code fine using VAXC or "cc"
>on Unix but Turbo C++ always gives me the above errror on my PC.
Ahh yes, the old missing floating point library - pitty they
don't fix this.
The problem is that TC does not "see" any statements in your
code which require floating point math so it "helps" you out
by not including it even though scanf() needs it!
One of the standard work arounds for this is to place a single
line in you code at the beginning like this:
exp(1.0) /* code to insure floating point inclusion */
then TC will "see" a statement that requires floating point
math [exp()] and include the floating point library for you.
Hope this helps.....................
-Brian
More information about the Comp.lang.c
mailing list