I've a program wich calculates much numbers, I can't store the data in an array because the RAM-memory isn't big enough for the data. So I wrote a bit of code wich puts the data in an .txt-file. In the same program I have to load it back piece by piece to display the data using openGL/ GLUT.
Now, the .txt file looks like this:
number1;number 2;number3;number4;......number N;
number1;number 2;number3;number4;......number N;
number1;number 2;number3;number4;......number N;
...................................................................................
number1;number 2;number3;number4;......number N;
Note that after number N; comes a "\n" (enter). And that a line is 2500 numbers long.
I have to load the data line by line so I use getline();
But every frame needs the next line.
To simplify a bit, here is the code to read:
ifstream file("example.txt", ifstream::in);
if(file.is_open())
{
getline(file, b);
cout<<b<<"\n"<<"\n";
file.close();
}
This code is not the code in the real program but it displays the problem.
The code works fine here, it simple loads the first line and displays it on the console screen. And does it each frame in openGL. so my console screen is continously updated every time opengl starts a new frame.
but when I add this:
ifstream file("example.txt", ifstream::in);
if(file.is_open())
{
getline(file, b);
strcpy(resultch, b.c_str());
cout<<b<<"\n"<<"\n";
file.close();
}
(Were resultch is declared as: char* resultch = new char[2550];
)
The code only runs 1 time and the program stops after it, the console screen than says:
proces returned -1073741819 <0x0000005>
Why does it not properly run each time?