Let's look into char type in C. Values of char type are small
integers - that's all. The range of char values depends on the C
language implementation: the language standard does not specify
whether char values are signed or unsigned integers. As usually,
char values ranges are -128..127 (VC compilers) or 0..255 (BC
compilers).
You may use chars in arithmetical expressions, assign them to int
variables (and vice versa). Constants of char type 'c' are integer
values of correspondent characters which are defined in the
internal (implementation-dependent) charset.
If assigned integer values are out of char type range, only least
significant bits are assigned (this truncation is not an error).
For example:
Code:
char c = 256; /* Don't use this truncation at home. */
if (c == 0) { /* That's true, now c has zero value! */
/* Did you understand why we came here? */
if (c == '0') { /* Oops, 0 != '0' */
}
}
Now let's return to your problem(s). Arbitrary expressions (even with 1-digit number operands) may have arbitrary result values. It's possible to calculate values which do not fit to char range. Yes, you can assign these values to char (with truncation) but what you want to do with this char?
You can convert text to int or char:
Code:
char data[] = "163";
int x = atoi(data); /* x == 163 */
char c = atoi(data); /* c != 163 now (can you explain why?) */
I'm in doubt that it's useful conversion...