char array to integer

H

hedylogus

I need to convert a char array to its corresponding unsigned integer value.
For example, if

char[0]=x (equivalent to 120)
char[1]=y (=121)
char[2]=z (=122)

then my integer value would be 120121122. My array is 32 char long...is
there a better way to do that than this:

char c_array[32], i_array[96];
i=sprintf ( i_array, "%u%u%u....%u", c_array[0],
c_array[1],...,c_array[31] );
my_int = atoi (i_array);

(i made i_array 96 since each char can be represented by a 3 digit number)

thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top