tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

strtoll question



Hello

Consider the program below and its output. Am I using strtoll() wrongly,
or is this a bug? (this is netbsd-7 branch)

$ cat /tmp/x.c
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>

int
main(void)
{
        const char *ptr = "999999999999999";
        char *endp;
        long long int res;

        errno = 0;
        res = strtoll(ptr, &endp, 0);
        printf("errno = %d\n", errno);
        printf("*endp = 0x%02x\n", *endp);
        printf("str %s\n", ptr);
        printf("num %lld\n", res);
        
        return 0;
}

$ cc -o /tmp/x /tmp/x.c 
$ /tmp/x
errno = 0
*endp = 0x00
str 999999999999999
num -1530494977


-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index