Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site xios.UUCP Path: utzoo!dciem!nrcaer!xios!greg From: greg@xios.UUCP (Greg Franks) Newsgroups: net.unix,net.bicycle Subject: Re: strtol() Message-ID: <351@xios.UUCP> Date: Thu, 6-Nov-86 14:34:06 EST Article-I.D.: xios.351 Posted: Thu Nov 6 14:34:06 1986 Date-Received: Sun, 9-Nov-86 07:24:38 EST References: <1366@mit-trillian.MIT.EDU> Reply-To: greg@xios.UUCP (Greg Franks) Organization: Xios Systems Corp., Ottawa, Ont. Lines: 34 Xref: dciem net.unix:9545 net.bicycle:3064 Summary: In article <1366@mit-trillian.MIT.EDU> rlk@athena.MIT.EDU writes: >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. (The reason I'm cross-posting it to net.bicycle is that >that's where the particlar program came from.) Our XENIX systems lack strtol too. My solution: getnum() { #ifdef V7 int i; if ( sscanf( lineptr, "%d", &i ) > 0 ) { while( isspace( *lineptr ) ) lineptr++; while( isdigit( *lineptr ) ) lineptr++; } else i = 0; return( i ); #else return (int)strtol(lineptr, &lineptr, 10); #endif } Strtol(3) adjusts lineptr by the number of characters eaten. So, after successfully grabbing the number using sscanf (which skips white space) adjust the pointer the hard way. There are public domain versions of strtok. Henry Spencer (utzoo) wrote one - I used his... Good luck! ..greg