[ back to toc ]


Date: 2001/12/06 20:36

Can you write me a code to delete record from binary file. and change a
record too

and using this data structure

typedef struct
int iproductNum[10];
int iproductType;
char description[max_size];
int iQty;
double dCost;
double dPrice;

to delete record

ask clt to enter iproductType
then look in the file if it is there
if not, print the error
it find, delete,set product to 0 and write it back to file.

to change record

if no record, print error
if find: call funtion(add) to add a new record
( I had function (add)

Just give me an idea what the code look like, I should be able to apply it
to my program.

Thank you in advance

The easiest and probably the most effective way is to read all the file
into memory, move the memory at the to-be-deleted record position down one
recod size and then write the file back.

On the other hand, I recommend that you use for the purpose some RDMBS
like, PostgreSQL, ORACLE or MySQL.

In C a file is just a series of bytes. There are nothing like records in C


[ back to toc ]