Memory problems, CSV, and Array
| Cbas (11) | |||
| 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...
Really stumped, any help will be much appreciated! | |||
| Duoas (1596) | |||
| The Nth element of an N-element array is numbered (N-1), not N. Accessing N is an error. You are just lucky it didn't crash the first time. Hope this helps. | |||
| Cbas (11) | |||
| ??? | |||
| Duoas (1596) | |||
Given
int a[20];the following is an error:
a[20] = 12; | |||
| Cbas (11) | |||
| Thank you(again) Duoas!! Oh, so I'm calling a value which doesn't exist. What about
Would that work? | |||
| Duoas (1596) | |||
| Of course. In C++, the elements of the array are always numbered 0..(N-1). Glad to help. | |||
This topic is archived - New replies not allowed.
