OxL Reference

method str.toCString

Copy with a trailing NUL byte (interior NULs are kept; C will stop at the first one).

Example:

oxl✓ checked in CI
import c "stdlib.h" { atoi }

fn main() io {
  let c = "1234".toCString()
  print("{unsafe { atoi(c.asPtr()) }}")
}
Output
1234
pub(api) fn toCString() -> CString

Complexity. O(n) in the length of the string (one copy).

Since. 1.0.0-beta

Returns

CString

Effects

none declared (pure unless the body says otherwise)

Defined in: std/ffi/ffi.oxl:90

See also