Intel® Fortran Compiler 18.0 Developer Guide and Reference

Character Constants

A character constant is a character string enclosed in delimiters (apostrophes or quotation marks). It takes one of the following forms:

[k_]'[ch...]' [C]

[k_]"[ch...]" [C]

k

Is the optional kind parameter: 1 (the default). It must be followed by an underscore ( _ ). Note that in character constants, the kind must precede the constant.

ch

Is an ASCII character.

C

Is a C string specifier. C strings can be used to define NUL-terminated strings. For more information, see C Strings in Character Constants.

Description

The value of a character constant is the string of characters between the delimiters. The value does not include the delimiters, but does include all blanks or tabs within the delimiters.

If a character constant is delimited by apostrophes, use two consecutive apostrophes ('' ) to place an apostrophe character in the character constant.

Similarly, if a character constant is delimited by quotation marks, use two consecutive quotation marks ("") to place a quotation mark character in the character constant.

The length of the character constant is the number of characters between the delimiters, but two consecutive delimiters are counted as one character.

The length of a character constant must be in the range of 0 to 7188. Each character occupies one byte of memory.

If a character constant appears in a numeric context (such as an expression on the right side of an arithmetic assignment statement), it is considered a Hollerith constant.

A zero-length character constant is represented by two consecutive apostrophes or quotation marks.

Examples

Valid Character Constants

"WHAT KIND TYPE? "

'TODAY''S DATE IS: '

"The average is: "

''

Invalid Character Constants

'HEADINGS

No trailing apostrophe.

'Map Number:"

Beginning delimiter does not match ending delimiter.

See Also