When multiple rows of a variable length data (VARCHAR or VARBINARY) are selected into a buffer, each new item begins at an index that is a multiple of datafmt->maxlength, even if the preceding item is less than datafmt->maxlength bytes long. This is illustrated in the code fragment below.
/* This example demonstrates selecting multiple rows of variable-length data into a buffer. In this case, the first row to be returned will have one column with the value "first string" and a second row with a column with the value "second string". */ datafmt.count = 2; datafmt.maxlength = 25; retcode = ct_results(cmd, &restype); if (retcode != CS_SUCCEED) { /* error handling code deleted */ . . . } if (restype == CS_ROW_RESULT) { retcode = ct_bind(cmd, 1, datafmt, buffer, CS_NULL, CS_NULL); if (retcode != CS_SUCCEED) { /* error handling code deleted */ . . . } retcode = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, &nrows); if (retcode != CS_SUCCEED) { /* error handling code deleted */ . . . } /* At this point, the string "first string" begins at buffer[0] and the string "second string" begins at buffer[25], even though the first data item was less than 25 characters long.*/ }