Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!alberta!calgary!marc@cpsc.UCalgary.CA From: marc@cpsc.UCalgary.CA (Marc Schroeder) Newsgroups: comp.sys.ibm.pc Subject: Re: scanf problem in TC v2.01. Message-ID: <2524@cs-spool.calgary.UUCP> Date: 22 Feb 90 15:36:58 GMT References: <204@sdscal.UUCP> <13317@cbnewsd.ATT.COM> Sender: news@calgary.UUCP Organization: U. of Calgary, Calgary, Alberta, Canada Lines: 48 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 . . char *string; float value; . . sscanf(string, "%f", &value); To convert a STRING to a DOUBLE, use the following format: #include . . 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