The concatenate operator, || or !!, is used to concatenate two strings to produce a string result.
The compound assignment operator ||= is also supported. The following two statements are equivalent:
s = s || s1; s ||= s1;
If both operands are bit strings, the concatenate operator produces a bit-string result. Otherwise, both operands are converted to character strings, and the concatenate operator produces a character-string result. If either operand is a wide character-string, both operands are converted to type WIDECHAR, and the result is WIDECHAR. For example:
C = ‘004100420043’Wx; /* wide ‘ABC’ */ D = ‘004400450046’Wx; /* wide ‘DEF’ */
C || D produces WIDECHAR string containing 0x004100420043004400450046 (length = 6).
The length of the string result is the sum of the lengths of the converted operands, as shown in the following example:
A = 'ABC'; B = 'XYZ';
In the previous example, A | | B produces ABCXYZ, and A | ! 5 produces ABC 5. The conversion rule that produces the blanks is explained in the topic Arithmetic to Character-String Conversion in the chapter Data Type Conversions.