unsigned short a;
char temp[] = "70000";
a = atoi(temp);
printf("a: %d\n", a);
Gives me the output a: 4464 when it should be a: 70000 Is there a better way to convert from ASCII to a decimal? The range of a unsigned short is 0 - 65535
As schnaader said, you may be running into an overflow problem.
But answering your printf question about outputting unsigned values, you want the u modifier (for "unsigned"). In this case, as Jens points out below, you want %hu:
printf("a: %hu\n", a);
...although just %u (unsigned int, rather than unsigned short) would probably work as well, because the short will get promoted to int when it gets pushed on the stack for printf.
But again, that's only if the value 70000 will fit in an unsigned short on your platform.