I have a function which i run three times. Its called float* departments(int a,float b, float c[], float d) and returns a 320 array
It runs perfectly twice, but on the third time window's gives me the error message:
The instruction at "0x7c93426d" reference memory at "0xc2940f10". The memory could not be "read" <Ok> to terminate, <cancel> to debug
I have no idea what is causing this crash,its obviously a memory thing(i think) but how do i fix it?
You are trying to write or read memory that doesn't belong to you. Look for anyplace that you can access memory outside the proper bounds. (If you can't see it, post your code.)
THANK YOU THANK YOU
Just one more thing.
My function, as well as returning an array, also outputs a file-the file name is specified by user.
The fucntion also runs three times, with the the option of running more if the user is not satisfied
float *make_float_array()
{
float *result =newfloat[10];
char filename[FILENAME_MAX];
cout<<"Please enter a filename where you would like the CSV file to be written\n And dont forget to type .CSV at the end"<<endl;
cin>>filename;
ofstream fileOUT(filename);
// fill array = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
...
fileOUT<<"Number of People in the System"<<","<<endl;
return result;
}
int main ()
{
//while loop
float *run1 = make_float_array();
information1 = run1[10]
delete[] *run1;
float *run2 = make_float_array();
information1 = run2[10]
delete[] *run2;
float *run3 = make_float_array();
information1 = run3[10]
delete[] *run2;
cout<<"Again";//if yes, run loop agian
The program loops, so the CSV file eventually has about 320 entries in three colums
The problem is, on about the 2nd loop(the 4th CSV created) The memory error occures. I Find if i delete any files in my working folder it seems to run maybe 3 times before i get the "Windows has encountered an error and has to end the program"