Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!mailrus!ncar!tank!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Strtol and strtoul... Message-ID: <21305@mimsy.umd.edu> Date: 15 Dec 89 23:44:52 GMT References: <3233@com50.C2S.MN.ORG> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 21 In article <3233@com50.C2S.MN.ORG> markc@com2serv.c2s.mn.org (Mark H. Colburn) writes: > unsigned long foo; > char *ptr; > > foo = strtoul("-12345", &ptr, 0); >... where would ptr point to? The call should return ULONG_MAX with errno >set to ERANGE, but does *ptr = '-' or '\0' (end of string) or is it >indeterminate? It looks as if it should point to '\0', but... It should return (unsigned long)-12345, which is typically either 53191 or 4294954951, and leave *ptr=='\0'. For foo = strtoul("340282366920938463463374607431768211456", &ptr, 0); which *is* too big (unless you have 128 bit `long's), it should return ULONG_MAX, errno==ERANGE, and *ptr=='\0'. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris