Is it possible to get each words of a line extracted with getline?
for example, with this example as a "test.txt" file:
18407111 2018-07-05 00:04:02 MHAM EIDW 42 S1REB RYR5GW 3726 JNEIE 837B Datum RYR IFR Undefined 1 1 2018-07-05 00:15:38 2018-07-05 00:22:56 111 extended
0.0 113416.9 479798.5 -0.2 3.6 0.0
I can get the first line in a loop with getline(file,line) but from this line, i want to browse each "words" that are in it starting with "18407111".
I tried something but i only managed to get the first word.
#include <iostream>
#include <fstream>
main() {
int info[100][6] = {0};
int i =0, j;
std::ifstream file {"test.txt"};
std::string line;
std::string word;
while (getline(file,line))
{
word = line.substr(0, line.find(" "));
std::cout << word << "\n";
std::stoi(word)>> info[i][0];
i++;
return 0;
}
}
I need those data separate in order to work with it like:
18407111
2018
07
05
00
04
02
MHAM
etc...