Hello i need some help to understand my work heres the code
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <fstream>
using namespace std;
struct cell1
{
int value1;
}
cell1Data;
struct cell2
{
int value2;
}
cell2Data;
int main(void)
{
ifstream myfile("example.txt");
if(!myfile.good())
return 0;
vector<cell1> data1;
vector<cell2> data2;
string line1;
string line2;
istringstream iss1;
istringstream iss2;
while(getline(myfile, line1))
{
for(int a = 0; a < line1.length(); a++)
{
if(line1[a] == ';')
{
line1.erase(a, line1.length());
}
}
iss1.clear();
iss1.str(line1);
iss1 >> cell1Data.value1;
data1.push_back(cell1Data);
}
while(getline(myfile, line2))
{
for(int b = 0; b < line2.length(); b++)
{
if(line2[b] == ';')
{
line2.erase(b, line2.length());
}
}
iss2.clear();
iss2.str(line2);
iss2 >> cell2Data.value2;
data2.push_back(cell2Data);
}
for(int c = 0; c < data1.size(); c++)
cout<<data1[c].value1<< endl;
for(int d = 0; d < data2.size(); d++)
cout<<data2[d].value2<< endl;
return 0;
}
the problem is when i use the first while loop i cant make the other one to work so i dont know whats affecting what really since (i think) i doubled everything