Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Can't find the BUG (http://www.go4expert.com/forums/bug-t12839/)

keizer 10Aug2008 14:59

Can't find the BUG
 
This is a part of a code i wrote, i BOLD-marked the problem,
an anyone fine it?


index = ((id%MAX_BORROW_SIZE)*(sizeof(
brw_movie)));

fseek(fp_borrowed, index, SEEK_SET);
fread(&temp, sizeof(brw_movie), 1, fp_borrowed);

if (temp.ordered == 1)
{
temp.ordered = 0;
fseek(fp_borrowed, index, SEEK_SET);

//temp.catalog_id = 0;
fwrite(&temp, sizeof(brw_movie), 1, fp_borrowed);
printf("Movie id# %d has been deleted from Borrowed Movies.\n", id);

// **************** CHECK *************** //

fseek(fp_borrowed, index, SEEK_SET);
fread(&temp, sizeof(brw_movie), 1, fp_borrowed);
printf(" --> %d\n", temp.ordered);



OUTPUT -->

What is the movie catalog no#? 22
Your fine is: 75.000000 due to lag of 15 days!
Movie id# 22 has been deleted from Borrowed Movies.
--> 1
The movie was already ordered by another customer (# 2).

xpi0t0s 10Aug2008 21:55

Re: Can't find the BUG
 
What happens if you comment out the line immediately before the bold printf?

keizer 10Aug2008 22:06

Re: Can't find the BUG
 
Its ok, thanks...
the problem was i opened the file as "r"
and couldn't write there...


Thanks anyways...
-Tal


All times are GMT +5.5. The time now is 11:59.