I’m trying to read from a .txt file some numbers separted by white space. ( max 4 numbers on a line).
- I get the line but how can I transform it into array of int then
after I move to the second line to overwrite the array?
Example:
.txt file
2 5 8 14 11
50 40 30 20 10
18 17 16 15 14
Code:
fstream f("C:\\n.txt");
string wtf;
int n;
while(f>>n)
{
getline(f,wtf);
//transform the wtf string into int array?
//do what ever...
//clear the array?
}
Use
std::istringstreamandstd::vector: