Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #43618

Re: errno

From Ike Naar <ike@iceland.freeshell.org>
Newsgroups comp.lang.c
Subject Re: errno
Date 2014-04-26 22:35 +0000
Organization A noiseless patient Spider
Message-ID <slrn3vfsllod5p.p4i.ike@iceland.freeshell.org> (permalink)
References <ljh687$b06$1@dont-email.me> <bs2lo7FsnqU1@mid.individual.net> <ljh7pp$ksq$1@dont-email.me>

Show all headers | View raw


On 2014-04-26, Bill Cunningham <nospam@nspam.invalid> wrote:
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <errno.h>
>> #include <string.h>
>>
>> int main(int argc, char *argv[])
>> {
>>    long int a;
>>    errno = 0;
>>    a = strtol(argv[1], NULL, 16);
>>    if (errno != 0)
>>        printf("%s\n", strerror(errno));
>>    printf("%ld\n", a);
>>    return 0;
>> }
> Thanks much! I typed
>
> /h2d fffffffffffffff
> And all that was printed was -1. I'm used to thinking that's an error but 
> there is those few weird functions...

That is why you should have used "%ld" instead of "%d" to
print the value of a. Had you used "%ld", the output would
not have been -1 but the equivalent of LONG_MAX.

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

errno "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-26 16:51 -0400
  Re: errno Eric Wolf <eric@boese-wolf.eu> - 2014-04-26 23:11 +0200
    Re: errno "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-26 17:17 -0400
      Re: errno Ike Naar <ike@iceland.freeshell.org> - 2014-04-26 22:35 +0000
        Re: errno "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-26 19:35 -0400
  Re: errno Richard <rgrdev_@gmail.com> - 2014-04-26 23:56 +0200
  Re: errno Barry Schwarz <schwarzb@dqel.com> - 2014-04-26 17:15 -0700
    Re: errno "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-26 20:23 -0400
      Re: errno "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-26 20:27 -0400
    Re: errno "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-26 20:42 -0400

csiph-web