How does C++ handle char literals that are assigned to unsigned char variables? 

  • Converts to signed char 
  • Preserves exact value 
  • Converts to int 
  • Triggers an error
When a char literal is assigned to an unsigned char variable, C++ preserves its exact value. If the char literal's value is negative, when assigned to an unsigned char, it wraps around using standard two's complement arithmetic.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *