The data is grouped into tracks where a new track starts after each line break as shown above (in the actual data there are thousands of tracks). Notice each track has a varying number of lines. The goal of the program will be to read through the data and count the number of lines in each track. The output of the program would look something like the following:
Number of lines in Track 1: 3
Number of lines in Track 2: 4
Number of lines in Track 3: 2 .... and so on
So far I have written the following code which I believe should read the total number of lines in the data:
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <istream>
usingnamespace std;
int main() {
int number_of_lines = 0;
std::string line;
std::ifstream myfile("file.dat");
while (std::getline(myfile, line))
{
++number_of_lines;
}
std::cout << "Number of lines in text file: " << number_of_lines;
system("pause");
return 0;
}
This code, however, will just count the total number of lines and not the number of lines per track. I'm not quite sure where to go from here. How do I make this program output the number of lines per track?