[Solved] What is the difference between these two declarations of char?? Which one is correct?


The first piece of code assigns the character '1', which has an ASCII value of 49. Printing this as a character will yield 1, while printing as a number will yield 49.

The second piece of code assigns the value 1. Printing it as a character yields an unprintable character with an implementation defined representation, while printing it as a number will yield 1.

As for which is “correct”, that depends on how you want to use it.

solved What is the difference between these two declarations of char?? Which one is correct?