Basic module

to_c_string

procedure · 1 overloadSource

A copy of s in newly allocated memory, followed by a zero byte, for passing to C. It is allocated with the context allocator; free it with free. A zero byte inside s ends the string for the C side.

to_c_string :: (s: string) -> *u8

Parameters

s: string

Returns

*u8
ExampleOpen in playground ↗
c := to_c_string("abc");
defer free(c);
assert(c[3] == 0 && to_string(c, 3) == "abc");

See also