1#include <iostream>
2#include <fstream>
3#include <sstream>
4#include <vector>
5
6int main()
7{
8 std::fstream file("myfile.txt");
9 std::vector<std::string> vec;
10
11 if(file.is_open())
12 {
13 std::string line;
14 bool Skip = true;
15
16 while(std::getline(file, line))
17 {
18 std::stringstream sstr(line);
19 std::string word;
20
21 while (std::getline(sstr, word, ' '))
22 {
23 if(!word.empty())
24 vec.emplace_back(word);
25
26 else if(word.empty() && Skip)
27 {
28 vec.emplace_back("NaN");
29 Skip = false;
30 }
31 }
32 Skip = true;
33 }
34 file.close();
35 }
36
37 for(size_t i = 0; i < vec.size(); ++i)
38 {
39 std::cout << vec[i] << " ";
40 if((i+1)%3 ==0) std::cout << std::endl;
41 }
42 return 0;
43}