Why do multicharacter literals exist in C and C++?

It makes it easier to pick out values in a memory dump.


enum state { waiting, running, stopped };


enum state { waiting = 'wait', running = 'run.', stopped = 'stop' };

a memory dump after the following statement:

s = stopped;

might look like:

00 00 00 02 . . . .

in the first case, vs:

73 74 6F 70 s t o p

using multicharacter literals. (of course whether it says ‘stop’ or ‘pots’ depends on byte ordering)

Leave a Comment