Added text input and file reading

This commit is contained in:
2024-09-17 13:03:07 +00:00
parent 3d57d7df0d
commit ff57a5dc6b
5 changed files with 37 additions and 0 deletions

20
src/main.rs Normal file
View File

@@ -0,0 +1,20 @@
use std::io;
use std::io::BufRead;
use std::io::Read;
use std::io::Error;
use std::fs::File;
fn main() -> std::io::Result<()> {
println!("Please enter the path to the config file. ");
let mut s=String::new();
let stdin = io::stdin();
let mut handle = stdin.lock();
handle.read_line(&mut s).unwrap();
let s: String = s.trim().parse().unwrap();
println!("You typed: {}",s);
let mut read = File::open(s)?;
let mut contents = String::new();
read.read_to_string(&mut contents)?;
println!("{}",contents);
Ok(())
}