I’m having an interesting error upon moving over to g++ compiling on RedHat after using Visual Studio previously.
I have a loop that looks like this:
for(unsigned int i = 0; i < data.size(); i ++){
for(int j = 0; j < data[i]->size; j++){
cout << data[i]->columns[j]<< ',';
}
cout << endl;
}
where data[i]->columns is string *, and the intent is to separate the output by commas.
Previously, this worked, however, today my output looks something like this:
,ata, two, three, four
,ata2, two, three, four
,ata3, two, three, four
Whereas if I change the code slightly to:
cout << datai[i]->columns[j] << endl;
I get:
data
two
three
four
data2
two
three
four
What could be causing it to overlap these characters with commas? This wasn’t occurring on the visual studio compiler.
It looked like the final entry in each row has a \r and/or \n.
So on four you get
"fourBREAK,"Your endl output seems to confirm this since you’re getting 2 line breaks after four.