random file access

This is a discussion on random file access within the C++ Programming forums, part of the General Programming Boards category; Does anyone out there know anything about random file access....

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    126

    random file access

    Does anyone out there know anything about random file access.

  2. #2
    Registered User
    Join Date
    Aug 2002
    Posts
    170
    Yes. What do you want to know about it? It is more complicated that normal read, write or append methods. You have to keep track of your position in the file. If you do an insert, then you have to move every character after the insert, and vice versa for a delete.
    Best Regards,

    Bonkey

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    126
    My teacher just had me start them, and I wasn't really sure where to start.

  4. #4
    Registered User adamviper's Avatar
    Join Date
    Nov 2002
    Posts
    132
    your teacher sounds like a dweeb!!! who is a MAC lover!!!!!

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    126
    He does love a good MAC.
    Last edited by bob20; 11-27-2002 at 08:30 AM.

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    126
    All of this aside, can anyone tell me a good place to start into random file access.

  7. #7
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >All of this aside, can anyone tell me a good place to start into random file access.
    Start off with a file opened in binary mode. Make sure that every record is the same size, padded if the data doesn't fill the record, then you can calculate an offset for the file, go directly to it, and read the correct record:

    file.seekg ( RECORD_SIZE * offset );

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. question on random file access
    By ygfperson in forum C++ Programming
    Replies: 1
    Last Post: 06-16-2002, 05:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21