OxL Справочник OxL
РусскийEnglish

method str.toCString

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

Example:

oxl✓ проверяется в CI
import c "stdlib.h" { atoi }

fn main() io {
  let c = "1234".toCString()
  print("{unsafe { atoi(c.asPtr()) }}")
}
Вывод
1234
pub(api) fn toCString() -> CString

Сложность. O(n) in the length of the string (one copy).

С версии. 1.0.0-beta

Возвращает

CString

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/ffi/ffi.oxl:90

См. также