B
Bill Cunningham
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 <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
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;
}
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 <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
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;
}