File processing program not workin...

This is a discussion on File processing program not workin... within the C Programming forums, part of the General Programming Boards category; Hi,
Below is a program to store structures in a file and can be able to update them. But somehow ...

File processing program not workin...

Hi,

Below is a program to store structures in a file and can be able to update them. But somehow the part where the storing information occurs has an error. The user has to type the record number to see if that record contains information, if it has, then the user can't overwrite it unless he deletes the information. But the program doesn't do this, somehow....And i have a seperate function used to create the actual file, and there's a menu for the user to choose what he/she wants to do. I only posted the related code below.

This is part of your problem. You should probably make this a binary file. "wb" is what you want.

The next part is the fact that it doesn't look like you ever reopen this file once it's been created. When you reopen it, you need to make sure and use "rb+" so that you can "update" the file. That is to say: edit it without deleting the entire thing (ie: so you don't truncate it).

The following is a program from my deitel C: HOW TO PROGRAM book. It uses "r+" and "w" with binary files. Are you saying that the code dosn't work? Can you try the code out on your computer and give me an answer? Coz there really is an error while running the code on my comp, saying "File could not be opened" ( see code ). Pls help , thnx in advance.

I nearly read through half the book. The book teachs C, and a few chapters for JAVA and C++. I love its exercises. But quazh and you both said that the way the code was written in the deitel book is wrong? Then pls one of your two of some other programmers give a hand and really tell me whats wrong? I tried rb+ and wb, still the same error ( or bug ). thnx