Why a char variable gets 'b' from assignment of 'ab', rather 'a'?
char c = 'ab'; printf("c: %c ", c);
Prints:
c: b
According to the standard, it is implementation defined. From 6.4.4.4 Character constants:
An integer character constant has type int. The value of an integer character constant containing a single character that maps to a single-byte execution character is the numerical value of the representation of the mapped character interpreted as an integer. The value of an integer character constant containing more than one character (e.g., 'ab'), or containing a character or escape sequence that does not map to a single-byte execution character, is implementation-defined.
2.1m questions
2.1m answers
60 comments
56.9k users