data CStr
Namespace of helpers for reading C strings.
Example:
use std.ffi { CStr }
import c "string.h" { strdup }
import c "stdlib.h" { free }
fn main() io {
let c = "copy me".toCString()
unsafe {
let d = strdup(c.asPtr())
print(CStr.fromPtr(d))
free(d.cast<u8>())
}
}Output
copy me
pub(api) data CStrSince. 1.0.0-beta
Methods
fromPtr | (p: *u8) -> strCopies the NUL-terminated bytes at p into a str ("" for a null pointer). |
Defined in: std/ffi/ffi.oxl:118