🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.ibm.pc.programmer
3 messages
3 total messages Started by Marty Olevitch Mon, 11 Jun 1990 19:59
atof() problem in Turbo C 2.0
#707
Author: Marty Olevitch
Date: Mon, 11 Jun 1990 19:59
35 lines
1437 bytes
Here is something I've just noticed in using the atof() library routine in
Turbo C 2.0. When the following test program is compiled with the "-DWEIRD"
option, the correct answer is printed. However, when "WEIRD" is not
#defined, the error message "scanf : floating point formats not linked" is
printed at runtime. Does the compilation of the sscanf() load in some other
code needed for atof()? If so, how do I get this code loaded without the
dummy call to sscanf() (which in the example is never executed).

Thanks,

Marty Olevitch				Internet: marty@wuphys.wustl.edu
Washington University			UUCP:     uunet!wugate!wuphys!marty
Physics Department, Campus Box 1105	Bitnet:   marty@wuphys.WUSTL
St Louis MO 63130 USA			Tel:      (314) 889-6285

/* atoftest */
#include <stdlib.h>

main()
{
	char s[10];
	double a;
	int yuck;

	sprintf(s," 1.00");

#ifdef WEIRD
	yuck = 0;
	if(yuck == 1)
		sscanf(s, "%f", &a);
#endif
	a = atof(s);
	printf("%f\n", a);

}
Re: atof() problem in Turbo C 2.0
#719
Author: John Bruno
Date: Tue, 12 Jun 1990 16:23
21 lines
1601 bytes
In article <1990Jun11.195944.26213@wuphys.wustl.edu> marty@wuphys.UUCP (Marty Olevitch) writes:
 >Here is something I've just noticed in using the atof() library routine in
 >Turbo C 2.0. When the following test program is compiled with the "-DWEIRD"
 >option, the correct answer is printed. However, when "WEIRD" is not
 >#defined, the error message "scanf : floating point formats not linked" is
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 >printed at runtime. Does the compilation of the sscanf() load in some other
 >code needed for atof()? If so, how do I get this code loaded without the
 >dummy call to sscanf() (which in the example is never executed).
 >
 >Thanks,
 >
 >Marty Olevitch				Internet: marty@wuphys.wustl.edu
 >Washington University			UUCP:     uunet!wugate!wuphys!marty
 >Physics Department, Campus Box 1105	Bitnet:   marty@wuphys.WUSTL
 >St Louis MO 63130 USA			Tel:      (314) 889-6285
 >
 > [Short program that calls atof() deleted]

Page 380 Turbo-C User's Guide (Using Floating Point Libraries)
---jb
Re: atof() problem in Turbo C 2.0
#761
Author: Hi Ho Silver
Date: Fri, 15 Jun 1990 23:37
20 lines
1595 bytes
In article <1990Jun11.195944.26213@wuphys.wustl.edu> marty@wuphys.UUCP (Marty Olevitch) writes:
$Here is something I've just noticed in using the atof() library routine in
$Turbo C 2.0. When the following test program is compiled with the "-DWEIRD"
$option, the correct answer is printed. However, when "WEIRD" is not
$#defined, the error message "scanf : floating point formats not linked" is
$printed at runtime. Does the compilation of the sscanf() load in some other
$code needed for atof()? If so, how do I get this code loaded without the
$dummy call to sscanf() (which in the example is never executed).

   I believe the usual solution to this is to include a line of the form

	exp (1);

in your code (any floating-point math call will do).  This forces the
floating point code to be linked in.
-- 
   /Nikebo \ Nikebo says "Nikebo knows how to post.  Just do it."\silver@xrtll/
  /---------\_____________________________________________________\----------/
 /yunexus!xrtll!silver (L, not 1)\ Hi Ho Silver \   just silver for short   /
/Silver:  Ever Searching for SNTF \  Life sucks. \  someone buy me a BEER! /
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads