The char data type

The char data type is the C data type that holds character data.

When an application reads a value from a CHAR column into a host variable of type char, Informix® ESQL/C pads this value with trailing blanks up to the size of the host variable. It leaves just one place for the null character that terminates the host array. The behavior is the same if an application reads a value from a VARCHAR (or NVARCHAR) column into a host variable of the char data type.

Declare a char data type with a length of [n + 1] (where n is the size of the column with values that you want read) to allow for the null terminator. Use the following syntax to declare a host variable of the char data type:
EXEC SQL BEGIN DECLARE SECTION;
   char ch_name[n + 1];
EXEC SQL END DECLARE SECTION;