[Gambas-user] About StrPtr()

Demosthenes Koptsis demosthenesk at ...626...
Sun Dec 12 09:54: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()?

On Sun, 2010-12-12 at 02:17 +0100, Benoît Minisini wrote:
> > i made an example for StrPtr, it is the next one,
> > 
> > ' Gambas module file
> > 
> > PUBLIC SUB Main()
> > 
> > DIM p AS Pointer
> > DIM s AS String
> > 
> > p = Alloc("this is a string")
> > 
> > 'READ #p, s
> > s = StrPtr(p)
> > PRINT s
> > Free(p)
> > 
> > END
> > 
> > I just want to question what is the difference between
> > 'READ #p, s
> > s = StrPtr(p)
> > 
> > both of them make the same work.
> 
> Where did you see that?
> 
> StrPtr() reads a C-like strig in memory (i.e. a string terminated by a zero 
> character).
> 
> READ #p, s reads the length of the string first (in a Gambas multi-bytes 
> specific internal format) and then reads the needed number of characters.
> 
> Regards,
> 

-- 
Regards,
Demosthenes





More information about the User mailing list