so I have a file that's structured like this
01
,
10
11
00
,
00
;
each line can only hold 2 0s or 1s, and there can be any amount of lines over 0 in between the commas and I need to count every line until there's a comma and append that value to an array then set the counter to 0. if the function finds a ; it saves that value then breaks the loop
currently I'm stuck on getting it to count up correctly, maybe I'm just not understanding how getline works
#include <iostream>
#include <fstream>
#include <string>
int main()
{
std::string line[4];
std::ifstream infile("in.txt");
std::ofstream outfile("inData.txt");
int x;
while(!infile.eof())
{
getline(infile,line[0],'\n'); // tried with a , for \n and that correctly increases x for every comma
++x;
std::cout << "x: " << x << "\n";
// if(getline(infile, line[0],';')) {break;}
// need to break if ; is found but from what I've seen it just makes it iterate once then break when I was using a , in the first getline
}
std::cin.get();
}