Ok, this is an odd problem for me, I know how to stop it from happening but I get incorrect functionality when I do.
This is a run time error that occurs when the program is shut down, I get the correct functionality up until that point.
Here is the code block
The error does not occur if I add the ',' delimiter to the second getline call but doing so gives me the incorrect functionality.
I am pulling integer values out of a .csv file if that helps.
This is a run time error that occurs when the program is shut down, I get the correct functionality up until that point.
Here is the code block
Code:
int xPos[32];
int yPos[32];
char buffer[256];
char line[255];
int i = 0;
string newstring;
// Convert all the input data to integer arrays
do
{
// Data before the comma
fIn.getline(line, sizeof(buffer), ',');
newstring.assign(line);
xPos[i] = atoi(newstring.c_str());
// Data after the comma
fIn.getline(line, sizeof(buffer));
newstring.assign(line);
yPos[i] = atoi(newstring.c_str());
// Increment array iterator and continue looping down the file's lines until end of file
i++;
}while(!fIn.eof());
fIn.close();
cout << xPos[31] << ", " << yPos[31] << endl;
I am pulling integer values out of a .csv file if that helps.
Comment