RAD Studio |  |

Wide-character And Multi-character Constants
See Also
Collapse All

Wide-character types can be used to represent a character that does not fit into the storage space allocated for a char type. A wide character is stored in a two-byte space. A character constant preceded immediately by an L is a wide-character constant of data type wchar_t (defined in stddef.h). For example:

Copy Code

    wchar_t ch = L'A';

When wchar_t is used in a C program it is a type defined in stddef.h header file. In a C++ program, wchar_t is a keyword that can represent distinct codes for any element of the largest extended character set in any of the supported locales. In CodeGear C++, wchar_t is the same size, signedness, and alignment requirement as an unsigned short type.

A string preceded immediately by an L is a wide-character string. The memory allocation for a string is two bytes per character. For example:

Copy Code

    wchar_t *str = L"ABCD";

Multi-character constants

The compiler also supports multi-character constants. Multi-character constants can consist of as many as four characters. For example, the constant, '\006\007\008\009' is valid only in a CodeGear C++ program. Multi-character constants are always 32-bit int values. The constants are not portable to other C++ compilers.

See Also

Constants

Integer Constants

Integer Constant Without L Or U

Floating Point Constants

Character Constants

The Three Char Types

Escape Sequences

String Constants

Enumeration Constants

Constants And Internal Representation

Internal Representation Of Numerical Types

Constant Expressions

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!