You can either return null terminated char pointers by externing the functions using functionname$z() style or include some BRL C module code that gives you direct access to BlitzMax string handling mechanics.
testcstrings.bmx
Import "testc.c"
Extern "C"
Function cstringfunction$()
Function czstringfunction$z()
End Extern
Print cstringfunction()
Print czstringfunction() testc.c
// return fully constructed BlitzMax string version
#include <brl.mod/blitz.mod/blitz_string.h>
BBString *cstringfunction()
{
return bbStringFromCString("hello world\n");
}
// return null terminated char pointer version
char *zcstringfunction()
{
return "hello zworld\n";
}
|