Read an argument from the commandline.

This commit is contained in:
Eli Ribble 2023-11-29 17:44:13 -07:00
parent 0d3effd9d2
commit d348df882a
1 changed files with 3 additions and 1 deletions

View File

@ -2,7 +2,9 @@ use std::fs::File;
use std::io::prelude::*; use std::io::prelude::*;
fn main() -> std::io::Result<()>{ fn main() -> std::io::Result<()>{
let mut file = File::create("foo.txt")?; let filename = std::env::args().nth(1).expect("no filename given");
let mut file = File::create(filename)?;
file.write_all(b"Hello, world!")?; file.write_all(b"Hello, world!")?;
Ok(()) Ok(())
} }