Updating a file random
Alternatively, if the file is not big, you can read all records with an initial loop and build the index table in memory only.A persistent index table could be added to the data file by reserving some head records for the id array. Griffith (406003213) // March 24th 2007 #include typedef struct Tool; void transfer(); void update(); void check(); int main()//serves as menu void transfer() //end transfer function void check() //end check function void update() fclose(nd Ptr); }//end transfer function It's quite a weak assumption that you just can fread and fseek in a file and access the proper data. Howerver you invokue undefined behaviour also with fflush(stdin). Or you use some other way of indexing e.g with something like  /* id of the record quantity=12 cost=123.12 name="Some name" Or you use for something like Berkeley DB also ( or how about using an embedded SQL library like sqlite?And of course you just have two elements but you will try to seek for over 100, which surely will not work. Here's some code which may work (at least has a good chance to run in one run) #include typedef struct Tool; static Tool test_data = ; static char *file_name = "tool_db.bin"; static void populate_file(void) enum; static int update_record(int id, char* new_name) void print_file(void) int main(void) Regards Friedrich Well of course the update stuff has to be put in a loop.
But accessing them by id Number (a data field in the record) cannot be mediated by fseek.
One even can think about the "one entry- one exit" control flow in C.
I know C makes it easy to just "jump" out if something goes wrong.
Initially there is nothing there (since newhardware has not been initialized), and so it displays random garbage for the record.
If you try it with record number 0, you will see that the entered name is preserved in the file, though. Do you wonder if your IT business is truly profitable or if you should raise your prices?