My curiosity got the better of me. What would happen (or does happen) when you write the code:
char pseudo_char = 256;
Would it store a virtual char with a value of 256? Or is this illegal and should never be done?
It's probably an overflow (unless CHAR_MAX >= 256). That's Undefined Behavior, and anything may happen. It's unlikely to format your harddisk.
This would be an undefined behavior. The range of char is -128 to +127 or 0 to 255 based on if it is signed or unsigned, so anything may happen in your case.
Would it store a virtual char with a value of 256?
It will show you an undefined behavior. Something which you cant predict.
Or is this illegal and should never be done?
I would not say that it is illegal but yes if you dont want to get into unpredictable environment then dont do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With