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


------------------------------------------------------------------------------
Oracle to DB2 Conversion Guide: Learn learn about native support for PL/SQL,
new data types, scalar functions, improved concurrency, built-in packages, 
OCI, SQL*Plus, data movement tools, best practices and more.
http://p.sf.net/sfu/oracle-sfdev2dev 
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to