[Gambas-user] About StrPtr()

Benoît Minisini gambas at ...1...
Sun Dec 12 02:17:41 CET 2010


> 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,

-- 
Benoît Minisini




More information about the User mailing list