Atoi

Programming, for all ages and all languages.
Post Reply
chris

Atoi

Post 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));
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Atoi

Post 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.
-- Stu --
Post Reply