# Char[] array to int

Hi All,

I am trying to pass a value to an integer variable.
My source value is in a char array like:
char s;
My destination is an integer like:
int d;

Also,
the values in s are Hex values such as,

s = 0A,
s = E2,
etc…

Suppose i only want to pass two of them, say Sum of the decimal equivalent of s and s into d.

s = A0 -> 160
s = E2 -> 226

so, d should be 160+226

how will i do that in Dynamic C 9.52?

kindly respond.

[QUOTE=#NewRab;1181]Hi All,

I am trying to pass a value to an integer variable.
My source value is in a char array like:
char s;
My destination is an integer like:
int d;

Also,
the values in s are Hex values such as,

s = 0A,
s = E2,
etc…

Suppose i only want to pass two of them, say Sum of the decimal equivalent of s and s into d.

s = A0 -> 160
s = E2 -> 226

so, d should be 160+226

how will i do that in Dynamic C 9.52?

kindly respond.[/quote]

Make sure that s[] is an unsigned char array, then it’s simply:

unsigned char s;
int d;

d = s + s;

Good luck!

Thank you! that works!!