I want to read a text file of the form.
15 23 63 52 58
11 254 55 36 22 547 55 2
22 58 66 3 11 4 7 5 2 8
48 49 23 88 62 33
How can I implement it in C++? The following code has been implemented by me.
while(!fin.eof()) {
getline(fin, str);
cout << str << "\n\n";
i++;
}
Here the numbers are in the form of a string. Since the code is a part of reading adjacency list of graph, I want the array of these numbers. For example, I want to create a C++ vector array
vector<int> abc[4];
where I will store all the corresponding numbers in the line. Please suggest a solution other than reading the numbers in form of string and splitting it. It should be concise than earlier one.