Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!sri-unix!hplabs!pyramid!amdahl!ames!oliveb!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.unix Subject: Re: strtol() Message-ID: <8848@sun.uucp> Date: Mon, 3-Nov-86 14:18:02 EST Article-I.D.: sun.8848 Posted: Mon Nov 3 14:18:02 1986 Date-Received: Tue, 4-Nov-86 07:49:21 EST References: <1366@mit-trillian.MIT.EDU> Organization: Sun Microsystems, Inc. Lines: 23 > What does this do? It doesn't seem to exist on my 4.3 system. I > suspect it's a SysV library fn, so it seems like I'll have to write it > myself. Yes, it's a generalization of "atol"; it first appeared in System V. It is passed a pointer to a "char *"; if this pointer is non-null, it will return a pointer to the first character after the value it converted. It is also passed a radix, so it can convert hex or octal numbers; if the radix is 0, it converts the number as if it were a C constant (if it begins with "0x", it's hex; otherwise, if it begins with "0", it's octal; otherwise, it's decimal). > getnum() > { > return (int)strtol(lineptr, &lineptr, 10); > } As you can probably infer, the "pointer to pointer" is the second argument and the radix is the third argument. -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)