I'm still bugging out!
Im writing a program to run the simulation of a workshop of a University. 320 jobs must be processed in under 3.5months. There are 3 departments. Cutting, welding and drilling. Everyone first goes to cutting, and a 70-30% split to welding, drilling respectively.
I've written one function, which i repeat three times.
The function creates an array of departure times-which will be used for the arrival time to the next department.
Displaying the values on the screen is not a problem, however i also output a CSV file with collums Job#, Que, Depart time. (A minor problem is that i write three different CSV-one for each department. It would be great if i could have it all on 1, but not such an issue.)
The whole program is in on a loop, so the user can run it several times, changing the amount of machines in each department, until an optimum value is reached(cost,time etc)
The problem is that on the 2nd or third loop the whole program crashes-with a windows error. I assume it is a memory problem and i am using space which isn't mine. Any ideas??
I've included a simplyfied bit of the code...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
float *department(int tot_ppl, float arrival_times[])
{
float *depart_time =new float[tot_ppl + 1];//I need two extra places
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);
// depart_times = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9...N };
...
fileOUT<<"Job#"<<","<<Que...<<endl;
depart_time[tot_ppl] = Que;
depart_time[tot_pple + 1]= (Que/2);
return depart_time;
}
int main ()
{
//create an array with arrival times ARVL[tot_ppl-1]
//while loop
float *cutting = make_float_array(people,ARVL);
//divide cutting into two arrays, call A B which I pass to welding
totaltime_cutting = cutting[tot_jobs-1]
delete[] cutting;
float *welding = make_float_array(w,A);
total_welding = welding[w-1]//where w is the last person to leave
delete [] welding;
float *drilling = make_float_array(b,B);
totaltime_drilling = drilling[d-1]
delete [] drilling;
///Compare the total times
cout<<"Again?";//if yes, run loop agian
|
Really stumped, any help will be much appreciated!