I have not thoroughly looked at your code yet, but in response to your above question:
You did correctly write to one spot on your 2D array table.
It was prompt to the user on the lower half of the source provided.
And you did write it successfully to the file; although probably not in a way you'd want it to be - current a integer value.
What your missing is your file reading process.
How are you to return the data back into the table on the next start up?
It is really up to you.
Read by integer? read by line? read by string?
Also, will you map the whole table on the text file, or will you have two indexes plus the value at its location?
You've still got a bit of designing to do.
How ever you are planning to read from file, you should consider writing the same way.
Think about it.
(ZZzzZZzz)
(Edit)Example:
Table: (Prior to modification)
- 0 1 2 3
- --------
0 0 0 0 0
1 0 0 0 0
2 0 0 0 0
3 0 0 0 0
4 0 0 0 0
5 0 0 0 0
Table: (After to modification) (say: factory:2-1, shift:4-1, integer:7(small for illustration purposes)
- 0 1 2 3
- --------
0 0 0 0 0
1 0 0 0 7
2 0 0 0 0
3 0 0 0 0
4 0 0 0 0
5 0 0 0 0
How are you to write this to file?
Currently:
outfile << factory[factorynum][shiftnum];
Appends the integer at that spot to your file
File:
7
My two quick judgement's are:
To write the who table to the file:
1 2 3 4 5 6
|
0 0 0 0 0
0 0 0 7
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
|
Or:
To write the two indexes followed by the integer value.
[code]0 4 7[code]
Consider using space, tab, or newline as delimiters reading/writing delimiters.
If not, you'll have to create your own character delimiters and parse your strings >_<