Article View: comp.std.c
Article #2208Re: "1234" ==> 1234 (char * ==> int)
From: Guy Harris
Date: Wed, 19 Dec 1990 19:01
Date: Wed, 19 Dec 1990 19:01
8 lines
931 bytes
931 bytes
>Use the atoi() or atol() function from the C library. Or, if you have it, "strtol()" (if you have ANSI C, you have it; even if you don't have ANSI C, you may have it). "strtol()" has the advantage that it tells you where it stopped scanning the string, so you can check whether the string was a number or just started out as one (e.g., you may not want to just convert "1234motorway" into 1234; you may want to let the user know that it's not a number).
Technical Details
Message-ID:
<4907@auspex.auspex.com>Path:
arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!auspex!guyReferences:
<1990Dec12.215359.5378@cs.utk.edu> <1990Dec13.044726.14433@zoo.toronto.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.std.c,comp.lang.c Subject: Re: "1234" ==> 1234 (char * ==> int) Message-ID: <4907@auspex.auspex.com> Date: 19 Dec 90 19:01:32 GMT References: <1990Dec12.215359.5378@cs.utk.edu> <1990Dec13.044726.14433@zoo.toronto.edu> Followup-To: comp.lang.c Organization: Auspex Systems, Santa Clara Lines: 8