Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Help in c++, going backwards through binary files

  • 29-03-2005 3:34pm
    #1
    Registered Users, Registered Users 2 Posts: 221 ✭✭


    I hope someone can help me
    i'm wondering how to search backwards through a binary file i havent
    done it in ages and can't remeber the notation

    if anyone can help that would be great thanks

    -Sean


Comments

  • Registered Users, Registered Users 2 Posts: 2,082 ✭✭✭Tobias Greeshman


    int start_pos = fgetpos(fp, &start_pos);

    Use the seek function to move to the end of the file
    fseek(fp, SEEK_END, 0L);

    Then use the above function
    do {
    int i = fseek(fp, SEEK_END, -chunk);
    } while(i != start_pos);

    You get the idea, get start position, move to end of file, read data there move back x bytes read that data, continue until you reach the start of the file.

    My code is probably a bit off, but ya get the idea (i've written it in C, but C++ standard library has similar functions to do the same thing).


Advertisement