#stdio #read-write #stdin #io #io-read #read #stdout

bin+lib soi-io

A simple library for reading and writing from stdin and stdout

4 releases

0.1.3 Sep 21, 2023
0.1.2 Sep 21, 2023
0.1.1 Sep 21, 2023
0.1.0 Sep 21, 2023

#38 in #stdout

MIT license

4KB

SOI

Provides simple io for reading and writing from stdin and stdout.

Usage

use soi_io::{read, read_vec, read_vec_len};

fn main() {
    // reads the first int from stdin
    let n: i32 = read();
    // reads the next 3 ints from stdin (on the same line)
    let v: Vec<usize> = read_vec_len(3);
    // reads the rest of the line as ints
    let v2: Vec<usize> = read_vec();
    println!("n: {}, v: {:?}, v2: {:?}", n, v, v2);
}

Example input:

1 2 3 4 5 6 7 8 9

Example output:

n: 1, v: [2, 3, 4], v2: [5, 6, 7, 8, 9]

Dependencies

~12KB