0
use std::io;

fn main(){
    let mut line = String::new();
    let input = io::stdin();

    println!("Enter First Number: ");
    input.read_line(&mut line).unwrap();
    let num1 = line.parse::<i32>().unwrap();

    println!("Enter Second Number: ");
    input.read_line(&mut line).unwrap();
    let num2 = line.parse::<i32>().unwrap();

    println!("Total = {}", get_sum(num1, num2));
}

fn get_sum(num1: i32, num2: i32) -> i32 {
    num1 + num2
}

Hello, in this code I am just trying to create a function that will add two numbers that the user inputs together. However after I type in the first number I get this error:

thread 'main' panicked at 'called Result::unwrap() on an Err value: ParseIntError { kind: InvalidDigit }', ../src/libcore\result.rs:785 note: Run with RUST_BACKTRACE=1 for a backtrace.

0 Answers0