[Gambas-user] About StrPtr()

Benoît Minisini gambas at ...1...
Sun Dec 12 19:01:15 CET 2010


> i just compared the output
> with PRINT s and i saw the same result.
> 
> i was wrong because i did not know about string manipulation in c.
> i did not understand the zero terminated string you mentioned in help.
> 
> i found some info at this page
> http://www.dfstermole.net/OAC/hstrings.html
> 
> Is there any way to produce a zero terminated string in Gambas to
> demostrate the StrPtr()?
> 

Yes, but I don't want to really explain that, as it is internal interpreter 
stuff.

Even if Gambas always knows the length of a string (by storing it with the 
string contents for example), all strings created by Gambas are zero-
terminated string. 

*But*, Gambas does not always create strings. For example, many string 
manipulation functions (Mid$, Left$, Right$, Trim$...) do not really create 
strings to be faster, and so do not return zero-terminated strings 
necessarily.

So, to be sure, just create a string with an explicit Chr$(0) at its end.

Regards,

-- 
Benoît Minisini




More information about the User mailing list