Help With Converting Char to Int

If xVal is always a single digit character, you don't need to convert it to a string. You can use:

pos = xVal - '0';   // '0' = a zero character

For example, suppose you get the single character '5' and assign it into xVal. If you look up the ASCII code for '5', you will find it equals 53. Likewise, the ASCII value for a zero character is 48. Then:

pos = xVal -'0';
pos = '5' - '0';
pos = 53 - 48;
pos = 5;

and is now a numeric value, rather than a character. If you get more than a single character, you'' need to convert it to a string.