Another C string passing question

BlitzMax Forums/BlitzMax Programming/Another C string passing question

splinux(Posted 2006) [#1]
I have to pass a string to a C file from a bmax one.

On the file there is:
char s[80];
void func(?)
{
...
}
and on the bmax file i need to write:
import "file.c"
extern
function func(?)
end extern

func("string")

What should i write on the places i've marked with a "?" ?


jamesmintram(Posted 2006) [#2]
Sorry - double post


jamesmintram(Posted 2006) [#3]
void func ( char *cString )

and

function func ( chars:byte ptr )

and then call it by:

func ( "string".tocstring () )

- Should work,


splinux(Posted 2006) [#4]
But after called the func function i have to do:

char s[80];

func(string)
s=string

and with this method isn't possible(i work char, not char *).


jamesmintram(Posted 2006) [#5]
You could use strcpy, ie:

strcpy ( &s, cString );

I think you would need to change the function decleration to:

func ( const char *cString )

http://www.cplusplus.com/ref/cstring/strcpy.html


splinux(Posted 2006) [#6]
Now i can't, but i'll try it as soon as possible.

thanks for your help.