ja**********@yahoo.com.cn wrote:
In my application,I use SQLBindCol to retrive the information, however
I found that in one table there is a varchar(10) column,
if the buffer size specified in the SQLBindCol is also ten,and the
buffer is ten length, then the result will be turned into 9.If the
buffer size specified as 11, then the result will be ok.
Does anyone explane for this?
The issue lies in the handling of strings in the C programming language. A
string is terminated by a trailing '\0' (= 0x00) byte to denote the end.
If you provide a buffer of 10 bytes, then only 9 bytes are available for
the actual data and the last byte is needed for the termination character.
That's a standard C/C++ thing, which needs to be solved by using buffers
that have (at least) one more byte than is needed for the real data.
--
Knut Stolze
DB2 Information Integration Development
IBM Germany