Can't find the BUG

Newbie Member
10Aug2008,14:59   #1
keizer's Avatar
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).
Mentor
10Aug2008,21:55   #2
xpi0t0s's Avatar
What happens if you comment out the line immediately before the bold printf?
Newbie Member
10Aug2008,22:06   #3
keizer's Avatar
Its ok, thanks...
the problem was i opened the file as "r"
and couldn't write there...


Thanks anyways...
-Tal