Read an argument from the commandline.
This commit is contained in:
parent
0d3effd9d2
commit
d348df882a
1 changed files with 3 additions and 1 deletions
|
@ -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(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue