Path: utzoo!attcan!uunet!mcvax!hp4nl!eutrc3!wzv!wietse From: wietse@wzv.UUCP (Wietse Z. Venema) Newsgroups: comp.lang.c Subject: Re: #include Summary: let the library do the hard work Keywords: something extra... Message-ID: <175@wzv.UUCP> Date: 21 Dec 88 22:38:04 GMT References: <354@greens.UUCP> Reply-To: wietse@wzv.UUCP (Wietse Z. Venema) Organization: Eindhoven University of Technology, The Netherlands Lines: 23 In article <354@greens.UUCP> matthew@sunpix.UUCP ( Sun NCAA) writes: > But no where could >I find a function to validate the string to see if it did contain a number >that atof(); would correctly interpret. >... >[BTW, isfloat(); can double for isdouble(); as can isint(); for islong();] > int isfloat(s) /* wants a null-terminated string with f.p. number */ char *s; { char junk = 0; float fval; return (sscanf(s,"%f%c",&fval,&junk) == 1); } Of course, you will want to keep the result of the string-to-float conversion. -- work: wswietse@eutrc3.uucp | Eindhoven University of Technology work: wswietse@heitue5.bitnet | Mathematics and Computing Science home: wietse@wzv.uucp | 5600 MB Eindhoven, The Netherlands