(1) Huh? unsigned char c; while(cin>>c) cout<<c<<'\n'; gives exactly what I expect
(2) The value of (unsigned char)0 *is* 0; not the value of the character '0'
- What exactly do you expect? Moreover, your thought experiment is incomplete, as you have provided no assumptions for the behavior of (cin >> c). I am sure that our expectations coincide on assumption that cin is empty
- But the text form of (unsigned char) 0 is the string "0", not the character '\0'.