use gets::gets; use std::ffi::{c_char, CStr}; fn main() { // Stupid warnings! I've programmed for years, I know what I'm doing! #[allow(warnings)] unsafe { // Serde did this, so it's fine, right? let mut buf: [c_char; 128] = std::mem::uninitialized(); println!("What is your name?"); // Surely nobody would ever input anything longer than 127 bytes? let ptr = gets(buf.as_mut_ptr()); if ptr.is_null() { return; } // Surely nobody would ever input invalid UTF-8? let name = CStr::from_ptr(ptr).to_str().unwrap_unchecked(); println!("Hello, {}!", name); } }