Re: hex to int
- From: "Bill Cunningham" <nospam@xxxxxxxxxxxxx>
- Date: Sun, 22 Feb 2009 15:53:29 -0500
"Bill Cunningham" <nospam@xxxxxxxxxxxxx> wrote in message
news:49a1ba14$0$5470$bbae4d71@xxxxxxxxxxxxxxxxxxxxxx
I have written this small program and I must admit I'm a little stuck.
Input should be a hex number like fff or 0xfff and convert it to the
decimal equivalent. The output I get is always 0.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
if (argc != 2) {
puts("hex usage error");
exit(EXIT_FAILURE);
}
int x = strtol(argv[1], NULL, 10);
printf("%i\n", x);
return 0;
}
Am I missing a std function here that could do this for me? I know error
checking is not present.
Bill
I see that strtol returns a long. Could this be part of the problem?
Bill
.
- Follow-Ups:
- Re: hex to int
- From: Joachim Schmitz
- Re: hex to int
- References:
- hex to int
- From: Bill Cunningham
- hex to int
- Prev by Date: hex to int
- Next by Date: Re: hex to int
- Previous by thread: hex to int
- Next by thread: Re: hex to int
- Index(es):
Relevant Pages
|