aa*****@gmail.com wrote:
what exactly is the purpose of multi-character constant..???
It's not 100% clear what you mean; an example would be helpful.
If you mean something like 'ab', the best answer is that if you have to
ask, you don't need to know. All the standard says is (C99 6.4.4.4p10):
The value of an integer character constant containing more than
one character (e.g., 'ab') [...] is implementation-defined.
In practice, the value of 'ab' is likely to be either 'a' * 256 + 'b'
or 'b' * 256 + 'a'. It will vary from one compiler to another.
The only place I've seen them actually used is in software for PalmOS,
where, if I recall correctly, they're used to provide unique 16-bit tags
for applications. Something like 'XY' that's related to the name of the
application is easier to remember than a numeric constant. In that
context, the actual value doesn't matter, just that each pair of
characters maps to a consistent and unique integer value. This depends
on every compiler using the same mapping, or on all applications being
compiled with the same compiler.
But a sufficiently perverse compiler could legally have all such
constants have the value 42.
Avoid such constants unless you really need them *and* you're prepared
to deal with the fact that they're inherently non-portable.
--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"