you must appreciate the scope of the pointer creation and life time...
you create a databloc in Plus! before calling the c++ function... this pointer can exist globaly to the script.
then in your c++ module you replace a string that is only created and available on the scope of hte particular function in c++ so once the function returns the pointer *test is no longer available, as you exit the scope of the function.
instead you should write to the pointer already supplied by Plus!, the databloc, so it will be readable by Plus! after modifications... or create a new memory allocation with the c++ function that you will need to release later on, to avoid memory leaks, buildups etc...
so you use ...
int function(char* string, int len)
{
// string is the pointer to your databloc you created in plus script
// len points to the maximum space allocated in the databloc, to make sure you dont exceed the limit.
return strncpy(string, "Hello World!", len);
}
this way you write to the same pointer which is valid in plus as well.
quote:
From script manual, databloc object
[string] ReadString(
[number] Offset,
[boolean,optional] ReadUnicode,
[number,optional] Size
);
you can specifically read ASCII you assigning ReadUnicode to FALSE as it is TRUE by default.