Master the fundamental concepts of rust for systems programming through this focused micro-challenge.
Rust adoption rides on calling existing C: librsvg in GNOME, Stylo in Firefox, OpenSSL-shaped dependencies via FFI. extern "C" disables name mangling and pins the System V AMD64 calling convention so symbols link cleanly.
rustLoading…
i32→int, f64→double, *const T→const T*\0; CString builds them, CStr reads them back#[repr(C)] on structs matches C field order and padding rulesEvery FFI call is unsafe because Rust cannot prove C upheld aliasing or lifetimes.
For this exercise, you will declare a C function, link a small C library, and wrap the call in a safe facade where possible. This task asks you to document pointer validity, because bindgen-generated bindings still crash when you pass a dangling *mut across the boundary.
Keep the relevant man page, ABI doc, or Rust reference chapter open while you work. When your output disagrees with the reference implementation on the same machine, the mismatch is usually an alignment rule, an off-by-one terminator, or a register slot you misread in GDB. Skim the official documentation for the tool or ABI named in the exercise; the prose changes, but register roles, syscall numbers, and ownership rules stay stable across releases.
Use Rust FFI to call a C library function.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it works