Rust基础(10)-读取命令行参数

读取命令行参数

案例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::env;

fn main() {
let args: Vec<String> = env::args().collect();
println!("size = {}",args.len());
println!("{:?}", args);

let a = &args[1];
println!("a = {}",a);

let a = &args[2];
println!("a = {}",a);

let a = &args[3];
println!("a = {}",a);
}

总结

本文编辑完毕

  • Copyrights © 2017-2023 Jason
  • Visitors: | Views:

谢谢打赏~

微信