I'm at the start of writing a csv-file parser for a file with around 8000 Ids. When running, after around half the Ids are read and printed, the Clion console starts overwriting the first outputs so that at the end of running the first Id in my consoles output is the 2626th instead of the first. What in my code is responsible for this?
When printing every read character before the switch starts, the output is complete. It also works with a smaller amount of Ids, when i shorten the amount in the csv to around 6000.
int main() {
string buffer;
char zeichen;
ifstream eingabe;
eingabe.open("../lib/Daten.csv");
int zustand=0;//0=Token, 1=Werte
if(eingabe){
while(!eingabe.eof()) {
eingabe.get(zeichen);
//cout<<zeichen; // with only this it works
switch(zeichen){
case';':
if(zustand==0){
cout<<"Token: "<<buffer<<"; ";
}
else if(zustand==1){
cout<<"Wert: "<<buffer<<"; ";
}
buffer="";
break;
case'\n':
if(zustand==0){
zustand=1;
cout<<"Token: "<<buffer<<endl;
}
else if(zustand==1){
cout<<"Wert: "<<buffer<<endl;
}
buffer="";
break;
default:
buffer+=zeichen;
break;
}
}
}
eingabe.close();
return 0;
}