Originally posted by Deepak Jain:
I think the qusetion here is why is the below code that assigns a character literal to byte not flashing a compiler error
byte c = 'k';
Where as
char c1 = 'k'
byte c = c1;
shows a compiler error.
Thanks
Deepak
That is because the compiler knows that the value of 'k' will fit into a byte without any lost of precision. In the second case, it doesn't know that the char value held in "c1" will fit into a byte -- as c1 is not a compile time constant.
Henry