Declaring character arrays

A character array can be of type CS_CHAR or char[]; however, the rules governing these two datatypes differ. When an array of type char[] is used as input, the precompiler checks that the array terminates with a null character. If the array is not null terminated, a precompiler runtime function returns an error. In contrast, an array of type CS_CHAR is not checked for null termination. Instead, the length of the input continues up to the null character, if present, or to the declared length of the array—whichever comes first.

When used as output, arrays of type char[] are padded with space characters (blank-padded) and null terminated. Arrays of type CS_CHAR are not blank padded, only null terminated.

A character array is scalar, because it represents a single string. Thus, you can select into an array of characters and get back just a single string. Also, unlike arrays of other datatypes, an array of characters can be a host input variable.

For more information on arrays, see “Using arrays”.