method str.toCString
Copy with a trailing NUL byte (interior NULs are kept; C will stop at the first one).
Example:
import c "stdlib.h" { atoi }
fn main() io {
let c = "1234".toCString()
print("{unsafe { atoi(c.asPtr()) }}")
}Output
1234
pub(api) fn toCString() -> CStringComplexity. O(n) in the length of the string (one copy).
Since. 1.0.0-beta
Returns
Effects
none declared (pure unless the body says otherwise)
Defined in: std/ffi/ffi.oxl:90