Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!mit.eternal-september.org!.POSTED!not-for-mail From: Richard Newsgroups: comp.lang.c Subject: Re: errno Date: Sat, 26 Apr 2014 23:56:02 +0200 Organization: http://www.ieee.org/ Lines: 30 Message-ID: <87ppk3n4b1.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mit.eternal-september.org; posting-host="4af8175e487d1d8249b5548b81726a30"; logging-data="1146"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18J7X2msYvt7+UmpX4SN6y0LuLfuER2j1U=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:SbLpZY5sGAHfzJFoeD1rkjsfARA= sha1:ji6hZ7L5DDt0ce3r6daxEOYgHus= Xref: csiph.com comp.lang.c:43617 "Bill Cunningham" writes: > My little utility doesn't print an errno value like it should. I have > tried to fix it but have failed. I've never really used errno.h but always > perror() so what am I doing wrong here. > > #include > #include > #include > #include > > int main(int argc, char *argv[]) > { > long int a; > errno = 0; > if ((a = strtol(argv[1], NULL, 16)) == -1) > printf("%s\n", strerror(errno)); > printf("%d\n", a); > return 0; > } > 0/10 Up yer game Bill. Even the regs who are chomping at the bit to show off aren't biting anymore. -- "Avoid hyperbole at all costs, its the most destructive argument on the planet" - Mark McIntyre in comp.lang.c