c++ - strtoul problem
- David Grimes (19/19) Feb 15 2004 1.c:
- David Grimes (5/24) Feb 17 2004 This is the correct behaviour according to the standard. (There is an
1.c: #include <stdio.h> #include <stdlib.h> #include <errno.h> int main(int argc, char *argv[]) { unsigned long number = strtoul(argv[1], 0, 10); if (errno) { perror("Incorrect integer value"); return 1; } printf("number = %lu\n", number); return 0; } dmc 1.c & 1 abc number = 0 Function strtoul doesn't set errno if the conversion can not be performed. David
Feb 15 2004
This is the correct behaviour according to the standard. (There is an erratum in the description of the function in my C book) David "David Grimes" <dgrimes friberg.us> wrote in message news:c0p42c$2vfh$1 digitaldaemon.com...1.c: #include <stdio.h> #include <stdlib.h> #include <errno.h> int main(int argc, char *argv[]) { unsigned long number = strtoul(argv[1], 0, 10); if (errno) { perror("Incorrect integer value"); return 1; } printf("number = %lu\n", number); return 0; } dmc 1.c & 1 abc number = 0 Function strtoul doesn't set errno if the conversion can not be performed. David
Feb 17 2004