Apologies if this is a little vague, but I really don't know what's happening.
Since I've added some file reading functionality to a simulation program it has started triggering breakpoints in various different parts of the code. Sometimes within the 'new' function, sometimes when it tries to open a pipe for gnuplot commands, and sometimes just at the end of the program.
Because none of this was happening before, and after a bit of debugging, I think that the cause is something to do with the combination of the file reading and dynamic memory allocation. But beyond that I really don't know what is causing this, especially because it only happens occasionally. Can anyone offer any advice on this?
EDIT: It's been pointed out that this isn't actually a breakpoint, but a visual studio error indicating a problem with the heap allocation. Similar to This other question, so I may just have to go away and check all of my dynamic memory pointers. This being said, I would still appreciate it if anyone has any advice they could offer about this.
Below are code snippets of the functions that I've added.
string input = "C:/Users/ME/Documents/Data/Cilium/Raw/size.dat";
ifstream fsRead(input.c_str());
//cout << "Reading file: " << "\n\t" << input.c_str() << endl;
j = 0;
while (fsRead >> inval)
{
Numpoints[j] = inval;
//cout << Numpoints[j] << endl;
j++;
}
j = 0;
fsRead.close();
...
[ITERATION LOOP]
{
int phase = it%T;
Ns = nearbyint(Numpoints[2 * phase + 0]);
ds = Numpoints[2 * phase + 1];
s = new double[5 * Ns];
if (phase == 0) phase = T;
input += to_string(phase);
input += ".dat";
ifstream fsRead(input.c_str());
//cout << "Reading file: " << "\n\t" << input.c_str() << endl;
j = 0;
while (fsRead >> inval)
{
if (j % 5 == 0) s[j] = inval + XDIM/2;
else s[j] = inval;
j++;
}
j = 0;
fsRead.close();
...
delete s;
}