Page 1 of 1

Atoi

Posted: Sat Jan 10, 2004 9:42 pm
by chris
I've got a char array and I'm not sure how to send one of the characters in it to atoi properly. Anybody know how?

Code: Select all

???char hex[MAX];

???result += (ret2 = atoi(?????)) * (ret = pow(16, i));
EDIT: would this be corrent?

Code: Select all

???char hex[MAX];

???result += (ret2 = atoi(&hex[i])) * (ret = pow(16, i));

Re:Atoi

Posted: Sun Jan 11, 2004 5:26 am
by df
that passes the address.

Code: Select all

result += (ret2 = atoi(hex[i])) * (ret = pow(16, i));
if its a hex number you want to use atoul not atoi or look into strtoul which can read ascii-hex into numeric.