Can't find the BUG

Discussion in 'C' started by keizer, Aug 10, 2008.

  1. keizer

    keizer New Member

    Joined:
    Aug 10, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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).
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    What happens if you comment out the line immediately before the bold printf?
     
  3. keizer

    keizer New Member

    Joined:
    Aug 10, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Its ok, thanks...
    the problem was i opened the file as "r"
    and couldn't write there...


    Thanks anyways...
    -Tal
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice