Re: hex to int
- From: "Joachim Schmitz" <nospam.jojo@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 22 Feb 2009 21:54:14 +0100
Bill Cunningham wrote:
"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?
No. See my other post
.
- References:
- hex to int
- From: Bill Cunningham
- Re: hex to int
- From: Bill Cunningham
- hex to int
- Prev by Date: Re: hex to int
- Next by Date: Re: Do address have some special format to separate with common integers?
- Previous by thread: Re: hex to int
- Next by thread: Re: hex to int
- Index(es):
Relevant Pages
|