why does this happen?

char ch;
int ii;
ch=200;
int=ch;
cout<<"ii ="<<ch;
the result is ii=-56 and not 200 why?is this because of the range of signed char?
is this because of the range of signed char?


Yes.

Assuming 2's compliment....
char's range is [-128..127]. Anything outside of that range causes wrapping. ie:

1
2
3
char x = 127;
++x;
// now x is -128 (wrapped around) 
Topic archived. No new replies allowed.