error: overflow in implicit constant conversion [-Werror=overflow]
#include<stdio.h>
int main()
{
char ch=200;
printf("\n%d",ch);
return 0;
}
I am running this code on http://ideone.com/YNkKT6#view_edit_box and getting the implicit conversion error. What modification do I need and what is the reason?
n3376 3.9.1/1
Plain char, signed char, and unsigned char are three distinct types. A char, a signed char, and an unsigned char occupy the same amount of storage and have the same alignment requirements (3.11); that is, they have the same object representation.
What is char
is implementation-defined, so, you need unsigned char
here, that handles values (0-255).
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