string variable

Monkey Forums/Monkey Programming/string variable

Emil_halim(Posted 2014) [#1]
Hi all,

i have an asm function that accept a pointer to bytes as a parameter , then i declared
it as extern function like that
Extern
   Function H_strcpy:Void(dest:byte[], source:byte[]) = "H_strcpy"
public


so when calling the function like that
    Local dststr:String="welcome"
    Local srcstr:String="12345678"
    H_strcpy(dststr,srcstr)
    Print  dststr

i got that error " Error : Type 'Byte' not found "
how to declare a null c string pointer , and how to pass c string pointer from string variable ?


AdamRedwoods(Posted 2014) [#2]
c++
you need to take the string variable
Extern
   Function Strcpy:Void( dest:String, src:String )

then src->ToCString() returns a null-terminated pointer.
to return to monkey, you must create a new String *dst = new String( array, len).
you can also do src->Data() for a const unicode char pointer, but it may not be null terminated (i don't know).