0

Why does it print an integer value when it is asked to print multiple characters (in single quotes)?

Please refer to the code attached. Compiler gave me a usual warning that multiple characters are there in single quotes. But the program compiles and it gives back an integer value. https://code.sololearn.com/cOInaQQ2VUP4/?ref=app

24th Feb 2020, 11:24 AM
Chetan Satpute
Chetan Satpute - avatar
2 Answers
+ 6
value of multicaracter literals are implementation-defined. multicharacter literal has type int, because it can't fit to char variable which has size only 1 byte. As it has type int your program prints integer value An ordinary character literal that contains more than one c-char is a multicharacter literal. A multicharacter literal, or an ordinary character literal containing a single c-char not representable in the execution character set, is conditionally-supported, has type int, and has an implementation-defined value.
24th Feb 2020, 12:11 PM
andriy kan
andriy kan - avatar
24th Feb 2020, 11:42 AM
Mihai Apostol
Mihai Apostol - avatar