Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

Read a floating point number from stdin

// Read a floating point number from stdin

use std::io;

fn main() {
    let num:f64;  //=0.0;
    let mut input = String::new();
    
    println!("Enter number: ");
    io::stdin().read_line(&mut input).expect("Not a valid string");
    num = input.trim().parse().expect("Not a valid number");
    println!("Number is: {}",num);
}
 
PREVIOUS NEXT
Tagged: #Read #floating #point #number #stdin
ADD COMMENT
Topic
Name
3+7 =