comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » String array from C
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
String array from C [message #65005] Thu, 05 February 2009 15:30
Robbie is currently offline  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
[Message index]
 
Read Message
Previous Topic: Is it possible to get the transformed Image Data from a Model Object
Next Topic: How to know how much memory (in Mb) takes an object ? 1700 on memory grObjects is too much?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 19:26:47 PDT 2025

Total time taken to generate the page: 0.32274 seconds