Getting input from file

How do i read file line by line as integer

suppose,
there is file
file.txt

1
2
3
4
5

and i want to read it as int vector or and arrya how do i do this.

The rust cookbook has examples for these sorts of "common" problems. In particular, you probably want to combine this recipe on reading lines in a file with str::parse().

2 Likes