Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

rust read lines from stdin and return a vec

//read lines from stdin and return a vector
fn readlines() -> Vec<String> {
    use std::io::prelude::*;
    let stdin = std::io::stdin();
    let v = stdin.lock().lines().map(|x| x.unwrap()).collect();
    v
}
// sample usage
fn main() {
    let f = readlines();
    println!("{:?}", f); 
}
 
PREVIOUS NEXT
Tagged: #rust #read #lines #stdin #return #vec
ADD COMMENT
Topic
Name
1+9 =