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!/
keith@sdscal.UUCP (Keith Jones) (02/17/90)
In article <25D8649A.24584@maccs.dcss.mcmaster.ca>, cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) writes: > In article <90043.093434CMH117@PSUVM.BITNET> CMH117@psuvm.psu.edu (Charles Hannum) writes: > $In article <25D4D935.3073@maccs.dcss.mcmaster.ca>, > $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! Well, I didn't quite believe it, but I made this test file and sure enough, the printf doesn't print out anything that even looks like it approximates PI. ----- to cut ----- or not to cut ----- main() { float f; char *string = "3.1415926"; f = atof( string ); printf( "pi = %f\n", f ); } ----- be it here ----- or there ----- The output to this program was: D:\ -> test -8209.00000 and I compiled it with: D:\ -> tcc test I'm not particularly worried about this bug, but I figured I might as well post the program. Enjoy, Keith. -- Keith Jones ...!calgary!spycal!sdscal!keith Stream Data Systems I don't have a signature because my pen Calgary, Alberta, Canada keeps scratching up my monitor.
darcy@druid.uucp (D'Arcy J.M. Cain) (02/19/90)
In article <204@sdscal.UUCP> keith@sdscal.UUCP (Keith Jones) writes: >Well, I didn't quite believe it, but I made this test file and sure enough, >the printf doesn't print out anything that even looks like it approximates >PI. > >----- to cut ----- or not to cut ----- >main() >{ > float f; > char *string = "3.1415926"; > > f = atof( string ); > printf( "pi = %f\n", f ); >} >----- be it here ----- or there ----- > >The output to this program was: > >D:\ -> test > >-8209.00000 > >and I compiled it with: > >D:\ -> tcc test > >I'm not particularly worried about this bug, but I figured I might as well >post the program. > There are a number of things you can do to fix this problem. The first is to pull out that reference manual and look up atof's prototype: double atof(char *str); Add the above line to your code and it should work. You may also want to make f a double and change the printf statement to: printf( "pi = %lf\n", f ); this will give you a little more precision. The moral of the story is *ALWAYS* compile with as many warnings turned on as your compiler will allow and prototype everything. I do this on Turbo C, Microsoft C, GNU C and any compiler that allows it and I don't consider a program correct until it compiles without a whisper. That philosophy would have caught the above "bug." -- D'Arcy J.M. Cain (darcy@druid) | Thank goodness we don't get all D'Arcy Cain Consulting | the government we pay for. West Hill, Ontario, Canada | (416) 281-6094 |
toma@tekgvs.LABS.TEK.COM (Tom Almy) (02/20/90)
In article <204@sdscal.UUCP> keith@sdscal.UUCP (Keith Jones) writes: >Well, I didn't quite believe it, but I made this test file and sure enough, >the printf doesn't print out anything that even looks like it approximates >PI. >main() >{ > float f; > char *string = "3.1415926"; > f = atof( string ); > printf( "pi = %f\n", f ); >} The "problem" is that C, in its infinite stupidity about data types, assumes that all functions return ints, unless you declare otherwise. So the nice atof() function, which returns a double, is treated in main() like it has returned an int, which promptly gets converted into a meaningless float value that is printed. If you add the declaration: double atof(); or, even better: double atof(const char *string); or include either stdlib.h or math.h, the program will run successfully. Tom Almy toma@tekgvs.labs.tek.com Standard Disclaimers Apply
klotz@cbnewsd.ATT.COM (david.a.klotzbach) (02/21/90)
> > ----- to cut ----- or not to cut ----- > main() > { > float f; float atof(); /*<--try this and it all works just fine */ > char *string = "3.1415926"; > > f = atof( string ); > printf( "pi = %f\n", f ); > } > ----- be it here ----- or there -----
mark.freedman@canremote.uucp (MARK FREEDMAN) (02/22/90)
tM>From: toma@tekgvs.LABS.TEK.COM (Tom Almy) tM>Subj: scanf problem in TC v2.01. tM>Orga: Tektronix, Inc., Beaverton, OR. tM>The "problem" is that C, in its infinite stupidity about data types, tM>assumes that all functions return ints, unless you declare otherwise. Gosh, could you tell me which language you use which is capable of correctly guessing what you want it to do ??? It's pretty pathetic when a programmer has to explicitly tell the machine how to get the desired results. :-)/2 (3 zillion MIPS, and it STILL can't read my mind) mark.freedman@canremote.uucp - Toronto, Ontario, Canada --- ~ DeLuxe 1.11a20 #4219 Chain me, beat me, make me code in PASCAL ...
marc@cpsc.UCalgary.CA (Marc Schroeder) (02/22/90)
I used to have trouble with this as well.. When using the atof() function, the program would COMPILE and LINK fine, but it would give me a run-time error (saying: "Scanf: floating point format not linked in", or something along those lines). There IS a way around this. You don't even have to use atof() if you don't want to (I just gave up on it). You can use sscanf() instead (atof() probably just calls sscanf() anyways).. To convert a STRING to a FLOAT, use the following format: #include <stdio.h> . . char *string; float value; . . sscanf(string, "%f", &value); To convert a STRING to a DOUBLE, use the following format: #include <stdio.h> . . char *string; double value; . . sscanf(string, "%lf", &value); After each call, string will remain unchanged, and value will contain the appropriate floating point number. Note that sscanf() returns an integer value (I believe it's the number of 'fields' successfully read in). /\ _ _ \ iNet/Envoy : m.schroeder (org. id = kort) ( / \/ \ / \ e-mail : marc@cpsc.UCalgary.CA / / / / \ ms@flip.cpsc.UCalgary.CA / / / (_/____/ Fidonet : Marc Schroeder @ 1:134/47 \__/ Marc A. Schroeder * 1st year computer science University of Calgary
toma@tekgvs.LABS.TEK.COM (Tom Almy) (02/23/90)
Well, there is a :-)/2, but I'll respond anyway. In article <90022202515808@masnet.uucp> mark.freedman@canremote.uucp (MARK FREEDMAN) writes: >tM>From: toma@tekgvs.LABS.TEK.COM (Tom Almy) >tM>The "problem" is that C, in its infinite stupidity about data types, >tM>assumes that all functions return ints, unless you declare otherwise. > Gosh, could you tell me which language you use which is capable of >correctly guessing what you want it to do ??? In this case, any language with tagged data, for instance LISP, Smalltalk, APL. Data types are checked at runtime. > It's pretty pathetic when a programmer has to explicitly tell the >machine how to get the desired results. > :-)/2 Maybe so, but if you have to explicitly tell what you want there is less chance for misunderstandings! Languages where this problem would not occur because of requirements for explicit declaration include Pascal, Modula-2, and C++ (to a limited extent). Other languages which have this problem include Assembler and Fortran. (I bet this is the first posting here which puts C in the same class as Fortran!) A more intelligent linker could also solve the problem by matching function prototypes (what the application assumes the function passes) with the actual function definitions. > (3 zillion MIPS, and it STILL can't read my mind) Maybe it's time to put those mips to work doing error checking! Tom Almy toma@tekgvs.labs.tek.com Standard Disclaimers Apply
cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) (02/27/90)
In article <2524@cs-spool.calgary.UUCP> marc@cpsc.UCalgary.CA (Marc Schroeder) writes:
$There IS a way around this. You don't even have to use atof() if you don't
$want to (I just gave up on it). You can use sscanf() instead (atof() probably
$just calls sscanf() anyways)..
Naw, it would be the other way around, since the purpose of atof is a
subset of the purpose of sscanf. What sscanf will do is take a chunk of
the string you feed it and send it to atof or atoi (or whatever, depending
on the desired result type) to be converted.
--
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