String array from C [message #65005] |
Thu, 05 February 2009 15:30 |
Robbie
Messages: 165 Registered: February 2006
|
Senior Member |
|
|
I've had some problems dealing with string arrays which have been
generated from a C program.
If I try LONG(str) or FIX(str) I will find that there are extra
characters which get processed, yet I don't see them when I try PRINT
and HELP.
I can workaround the problem by using LONG(STRMID(0,str)) and FIX
(STRMID(0,str)).
Perhaps I have string processing mixed up. But, I thought that
IDL_StrEnsureLength took are of everything. I've changed my C code and
the problem has gone away, but I still don't understand why.
The original C code was:
char* v = PQgetvalue(Res,row,col);
int vl = strlen(v);
IDL_StrEnsureLength(&(pisArray[i]), vl);
strncpy(pisArray[i].s, v, vl);
The new C code is:
char* v = PQgetvalue(Res,row,col);
int vl = strlen(v);
IDL_StrEnsureLength(&(pisArray[i]), vl+1);
strncpy(pisArray[i].s, v, vl+1);
pisArray[i].slen = vl;
Thanks
Robbie
|
|
|