i have an assignment about file handling.
i am saving data to file in binary format using following statement
fpt = fopen("stock.dat", "ab");
fwrite( &a, sizeof(a), 1, fpt );
where a is object of class data
for printing file contents my code is
fpt = fopen("stock.dat", "r");
while ( feof(fpt) == 0 )
fread( &a, sizeof(a), 1, fpt );
now problem is here, at time of printing file contents is showing last record twice. What should i do ?
Also give me the idea to display the selected records using conditon given by user ( dbase style )
Code is also attached with this thread.