Since the file is saved in a text format, it is very annoying to try and 'edit' it. Instead you should read in the entire file to data structures, close the file, and then write over it again, clearing what used to be there to replace it with the changed data. If it were binary format you could simply change the relevant bytes, but I think that is outside the scope of your assignment, right?
The file extension tells you nothing about the actual format of the file.
eastw wrote:
any hints to my question?
L B wrote:
Since the file is saved in a text format, it is very annoying to try and 'edit' it. Instead you should read in the entire file to data structures, close the file, and then write over it again, clearing what used to be there to replace it with the changed data.
//C equivalent
typedefstruct level
{
int id;
char name[255];
float *sales_list[12];
struct level* nextnode; // make a linked list ? :D
}levelnode;
keep reading your .dat file (which is a text file) and make one record of the map, insert in the map. Read in the full file into the map. close the file.
Now whatever you need to change, take the input from user, lets say id = 10 and sales month = 5 (200.00); Change it to new values; keep doing this until the user asks to close the program;
truncate the file, write the whole map/linked list to the file and exit.