0
Time                     Inside   Entry   Exit  
Fri Sep 27 15:06:44 2019    3       8      5
Fri Sep 27 15:07:42 2019    5       10     5
Fri Sep 27 15:19:38 2019    4       9      5
Fri Sep 27 15:20:39 2019    4       9      5
Fri Sep 27 15:57:30 2019    3       8      5

This is my input file. I want to retrieve the last value from the column Inside. I can retrieve whole data from that file. Tried using fscanf(). But it won't work.I'm using Qtcreator for this.

string line;
  ifstream myfile ("Count.csv");
  if (myfile.is_open())
  {
    while ( myfile.good() )
    {
      getline (myfile,line);
      cout << line<<endl;
    }
  • 2
    You should avoid [while (file.good())](https://stackoverflow.com/questions/5605125/why-is-iostreameof-inside-a-loop-condition-i-e-while-stream-eof-cons). You could change it to `while (getline (myfile,line))` – Thomas Sablik Sep 28 '19 at 12:46
  • If you know the line length, you can start reading from the end of the file minus the maximum line length (plus possibly some extra for better alignment, partial record handling or corrupted data). Then you scan for next line and start the loop from that point. – Phil1970 Sep 28 '19 at 12:48

0 Answers0