[alt.msdos.programmer] scanf problem in TC v2.01.

alawlor@dit.ie (Aengus Lawlor) (02/09/90)

I'm having a problem using scanf in Turbo C 2.01.

When I have the code

         fscanf(f,"%f",x);

it compiles and links fine, but at run time I get

 scanf : floating point formats not linked
Abnormal program termination

The same code compiles and runs fine under TC v1.5.
any suggestions? (I've already tried RTFM. Twice!)
(TC v2.01 is exhibiting other buggy behaviour, including hanging, and odd chars
on the screen, esp when run on a network. Is it only me, or are other people
having problems? )
-- 
Aengus Lawlor    Dept of Computer Science.           Time flies like an arrow,
ALAWLOR@DIT.IE   Dublin Institute of Technology.     Fruit-flies like a banana
                 Kevin Street. Dublin 8. Ireland.   

semicon@watsci.uwaterloo.ca (Robert Adsett) (02/10/90)

In article <7192.25d1e107@dit.ie> alawlor@dit.ie (Aengus Lawlor) writes:
>I'm having a problem using scanf in Turbo C 2.01.
>it compiles and links fine, but at run time I get
>
> scanf : floating point formats not linked
>Abnormal program termination

  This is a known bug.  There is a fix for it (available on Simtel20 and
probably from Borland).  Until you get it put a line like
  (void)exp(1.0);
in your main().  It's ugly but it does get the FP formats loaded.

>(TC v2.01 is exhibiting other buggy behaviour, including hanging, and
>odd chars on the screen, esp when run on a network. Is it only me, or
>are other people having problems? )
   This is a new one on me.  Is some one messing up the .cfg or .tc
configuration files?   Any more details?  If you are using TC regularly
I suggest that you subscribe to TURBOC-L.  There are a fair number of
users subscribed to it and if there is a known bug you are running into
someone will know about it.  There is also a bug list maintained there.
( Oh send a one line mail message (the one line is "help") to
listserv@ucf1vm.bitnet for more info)



--
		Robert Adsett  <semicon@watsci.UWaterloo.ca>
		Dept. of Phys, Univ. of Waterloo, Waterloo Ont. Canada

dmurdoch@watstat.waterloo.edu (Duncan Murdoch) (02/10/90)

In article <7192.25d1e107@dit.ie> alawlor@dit.ie (Aengus Lawlor) writes:
>I'm having a problem using scanf in Turbo C 2.01.
>
>When I have the code
>
>         fscanf(f,"%f",x);
>
>it compiles and links fine, but at run time I get
>
> scanf : floating point formats not linked
>Abnormal program termination

I saw this bug about a year ago, and found a fix for it.  The details are hazy,
so you'll have to do some work:

The problem is that sometimes TC forgets to link in the floating point formats,
just as the message says.  I don't know the exact conditions to force linking,
but an explicit reference to a certain routine is sufficient.  The routine is
named something like __turbofloat.  You'll have to use TDUMP on a .OBJ file
that works, and look through the externals it declares, to find the exact name.
Then add a line something like
  if (1 == 0 )
     __turbofloat();
to force it to be linked in.

Sorry I can't be more precise, but I only use C when I have to.

Duncan Murdoch

cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) (02/11/90)

In article <7192.25d1e107@dit.ie> alawlor@dit.ie (Aengus Lawlor) writes:
$I'm having a problem using scanf in Turbo C 2.01.
$When I have the code
$         fscanf(f,"%f",x);
$it compiles and links fine, but at run time I get
$ scanf : floating point formats not linked
$Abnormal program termination

   I've had problems with scanf under TCC 2.0.  Given something like
scanf ("%f", &floatvariable);
it will read the keyboard but return garbage (sometimes 0, sometimes NAN,
sometimes other values).  atof is the cause of this problem; I've
tried
scanf ("%s", stringvariable); floatvariable = atof (stringvariable);
and it has the same problem (not surprising, since scanf calls atof
to handle floating point quantities).

$Aengus Lawlor    Dept of Computer Science.           Time flies like an arrow,
$ALAWLOR@DIT.IE   Dublin Institute of Technology.     Fruit-flies like a banana
$                 Kevin Street. Dublin 8. Ireland.   
   And time flies when you're having fun.
-- 
Stephen M. Dunn                               cs4g6ag@maccs.dcss.mcmaster.ca
          <std_disclaimer.h> = "\nI'm only an undergraduate!!!\n";
****************************************************************************
               I Think I'm Going Bald - Caress of Steel, Rush

cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) (02/11/90)

In article <1487@maytag.waterloo.edu> dmurdoch@watstat.waterloo.edu (Duncan Murdoch) writes:
$The problem is that sometimes TC forgets to link in the floating point formats,
$just as the message says.  I don't know the exact conditions to force linking,
$but an explicit reference to a certain routine is sufficient.  The routine is
$named something like __turbofloat.  You'll have to use TDUMP on a .OBJ file
$that works, and look through the externals it declares, to find the exact name.
$Then add a line something like
$  if (1 == 0 )
$     __turbofloat();

   Assuming that Duncan is correct about the routine name as being
__turbofloat, note that the call would have to be

if (1 == 0)
   _turbofloat ();

since C compilers prepend symbol names with underscores upon compilation.

-- 
Stephen M. Dunn                               cs4g6ag@maccs.dcss.mcmaster.ca
          <std_disclaimer.h> = "\nI'm only an undergraduate!!!\n";
****************************************************************************
               I Think I'm Going Bald - Caress of Steel, Rush

brent@sactoh0.UUCP (Brent K. Barrett) (02/11/90)

In article <7192.25d1e107@dit.ie> (Aengus Lawlor) writes:
>I'm having a problem using scanf in Turbo C 2.01.
>
>When I have the code
>
>         fscanf(f,"%f",x);
>
>it compiles and links fine, but at run time I get
>
> scanf : floating point formats not linked
 
 One way to get around this is to link in the emu.lib or fp87.lib
libraries *before* the standard library.  This forces TC to link in
the floating point package for printf/scanf.
 
 BTW, what is TC 2.01?  Never heard of it.  Where did you purchase
it?

-- 
  ////////      Novucivitas: The Future of Citadel       //////// 
 ///    US 916 784 9432 3/12/2400 bps GEMAIL: B.K.BARRETT    /// 
////////          ..ames!pacbell!sactoh0!brent         //////// 

tarvaine@tukki.jyu.fi (Tapani Tarvainen) (02/12/90)

In article <1487@maytag.waterloo.edu> dmurdoch@watstat.waterloo.edu (Duncan Murdoch) writes:
>>         fscanf(f,"%f",x);

>> scanf : floating point formats not linked

>Then add a line something like
>  if (1 == 0 )
>     __turbofloat();


It should be  
	_turboFloat()  
(with capital F)

-- 
Tapani Tarvainen    (tarvaine@jyu.fi, tarvainen@finjyu.bitnet)

CMH117@psuvm.psu.edu (Charles Hannum) (02/12/90)

In article <25D4D935.3073@maccs.dcss.mcmaster.ca>,
cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) says:
>
>In article <7192.25d1e107@dit.ie> alawlor@dit.ie (Aengus Lawlor) writes:
>$I'm having a problem using scanf in Turbo C 2.01.
>$When I have the code
>$         fscanf(f,"%f",x);
>$it compiles and links fine, but at run time I get
>$ scanf : floating point formats not linked
>$Abnormal program termination
>
>   I've had problems with scanf under TCC 2.0.  Given something like
>scanf ("%f", &floatvariable);
>it will read the keyboard but return garbage (sometimes 0, sometimes NAN,
>sometimes other values).  atof is the cause of this problem; I've
>tried
>scanf ("%s", stringvariable); floatvariable = atof (stringvariable);
>and it has the same problem (not surprising, since scanf calls atof
>to handle floating point quantities).

Please, people!  If you're going to post bug reports, please give SPECIFIC
EXAMPLES so us hackers can trace down the offending bug and obliterate it!
Generalized statements like this ARE NOT HELPFUL!


Virtually,
- Charles Martin Hannum II       "Klein bottle for sale ... inquire within."
    (That's Charles to you!)     "To life immortal!"
  cmh117@psuvm.{bitnet,psu.edu}  "No noozzzz izzz netzzzsnoozzzzz..."
  c9h@psuecl.{bitnet,psu.edu}    "Mem'ry, all alone in the moonlight ..."

bg0l+@andrew.cmu.edu (Bruce E. Golightly) (02/13/90)

I just looked at this problem. As far as I can tell, TC simply doesn't link
the floating point routines if the only references are *printf or atof. The
solution I obtained from other sources was to include the statement:


              (void)exp(1.0);

somewhere in the code. This call need be done only once, and it appears to
force TC to link the necessary routines.

BTW - I got this solution from somebody on the "C" bboard, and got my ears
pinned back for daring to post a question about TC on that board. They ain't
the friendliest people in the world over there.

alawlor@dit.ie (Aengus Lawlor) (02/13/90)

In article <2536@sactoh0.UUCP>, brent@sactoh0.UUCP (Brent K. Barrett) writes:
> In article <7192.25d1e107@dit.ie> (Aengus Lawlor) writes:
>>I'm having a problem using scanf in Turbo C 2.01.
>>
>>When I have the code
>>
>>         fscanf(f,"%f",x);
>>
>>it compiles and links fine, but at run time I get
>>
>> scanf : floating point formats not linked
>  
>  One way to get around this is to link in the emu.lib or fp87.lib
> libraries *before* the standard library.  This forces TC to link in
> the floating point package for printf/scanf.

Stephen Trier (thanks, Stephen) of Smith Undergrad Lab, CWRU, Cleveland OH.
told me to put
	exp(1);
in my program before the scanf, and this would solve the problem. It does!
I'm not going to try any harder than that to fix this bug!
>  
>  BTW, what is TC 2.01?  Never heard of it.  Where did you purchase
> it?
I got it from Borland UK, who offer Borland products to students and
Educational establishments at ~ price, and Lab Packs (10 sets of discs, 1 set
of manuals) for ~ one third of the price for 10 full price copies.

The manuals say ver 2.0 on the title page, but the opening screen, and the
readme specify 2.01. The files are dated May 11, 89. The readme doesn't
indicate what differences there may be between 2.0 and 2.01.

> 
> -- 
>   ////////      Novucivitas: The Future of Citadel       //////// 
>  ///    US 916 784 9432 3/12/2400 bps GEMAIL: B.K.BARRETT    /// 
> ////////          ..ames!pacbell!sactoh0!brent         //////// 
-- 
Aengus Lawlor    Dept of Computer Science.           Time flies like an arrow,
ALAWLOR@DIT.IE   Dublin Institute of Technology.     Fruit-flies like a banana
                 Kevin Street. Dublin 8. Ireland.   

cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) (02/14/90)

In article <90043.093434CMH117@PSUVM.BITNET> CMH117@psuvm.psu.edu (Charles Hannum) writes:
$In article <25D4D935.3073@maccs.dcss.mcmaster.ca>,
$cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) says:
$>   I've had problems with scanf under TCC 2.0.  Given something like
$>scanf ("%f", &floatvariable);
$>it will read the keyboard but return garbage (sometimes 0, sometimes NAN,
$>sometimes other values).  atof is the cause of this problem; I've
$>tried
$>scanf ("%s", stringvariable); floatvariable = atof (stringvariable);
$>and it has the same problem (not surprising, since scanf calls atof
$>to handle floating point quantities).
$Please, people!  If you're going to post bug reports, please give SPECIFIC
$EXAMPLES so us hackers can trace down the offending bug and obliterate it!
$Generalized statements like this ARE NOT HELPFUL!

   Uh ... other than filling in the name of your favourite floating
point variable, that's pretty specific.  If the memory model matters,
I've only tried it in the small model.  Floating point array elements
or scalars have the same problem.

-- 
Stephen M. Dunn                               cs4g6ag@maccs.dcss.mcmaster.ca
          <std_disclaimer.h> = "\nI'm only an undergraduate!!!\n";
****************************************************************************
               I Think I'm Going Bald - Caress of Steel, Rush

wcf@psuhcx.psu.edu (Bill Fenner) (02/14/90)

In article <90043.093434CMH117@PSUVM.BITNET> CMH117@psuvm.psu.edu (Charles Hannum) writes:
|In article <25D4D935.3073@maccs.dcss.mcmaster.ca>,
|cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) says:
|>   I've had problems with scanf under TCC 2.0.  Given something like
|>scanf ("%f", &floatvariable);
|>it will read the keyboard but return garbage (sometimes 0, sometimes NAN,
|>sometimes other values).  atof is the cause of this problem; I've
|>tried
|>scanf ("%s", stringvariable); floatvariable = atof (stringvariable);
|>and it has the same problem (not surprising, since scanf calls atof
|>to handle floating point quantities).
|Please, people!  If you're going to post bug reports, please give SPECIFIC
|EXAMPLES so us hackers can trace down the offending bug and obliterate it!
|Generalized statements like this ARE NOT HELPFUL!

Um, Charles, that looks pretty specific to me.  Or can't you write a little
program?  Here, I'll sketch something in for you.

main()
{
	float floatvariable;
	char stringvariable[50];

	scanf("%f",&floatvariable);
	printf("got %f\n",floatvariable);
	scanf("%s",stringvariable);
	floatvariable=atof(stringvariable);
	printf("got %f\n",floatvariable);
}

Is that good enough, Charles?  Or did you want me to include the output from
the debugger as it runs?  (ok, so maybe some sample input and output would be
nice; I don't have TCC so I can't give you any.)

You should have at least tried a program first and seen if you could duplicate
the problem, instead of flaming the guy for not having wasted bandwidth with a
program shell.

(strangely enough, I got funky results from the second one on this machine
(Harris HCX/UX); the first worked fine...)
Script started on Tue Feb 13 19:28:36 1990
(psuhcx)1 /usr3/wcf> test
1.2
got 1.200000
1.4
got 1085485875.000000
(psuhcx)2 /usr3/wcf> exit
exit

script done on Tue Feb 13 19:28:46 1990

Anyway, I'm getting off track.  Charles, you were wrong to yell at the guy, it
took me 30 seconds to type in the code around the lines he gave.
-- 
Bill Fenner                   wcf@hcx.psu.edu             ..!psuvax1!psuhcx!wcf
sysop@hogbbs.fidonet.org (1:129/87 - 814/238-9633)     ..!lll-winken!/