Thread: Reading file

  1. #1
    Join Date
    Sep 2003

    Reading file

    I need to scan an entire text file and I would like to know which is the best between copying the whole thing into memory and loading it part by part.
    The file is not, or at least I don't think it could be, a large file, it is some sort of simple script for some simple tasks... (actually, it does not have a real goal except to make me discover a little more about programming)

    Thanks to all who will answer this.
    Last edited by lyx; 11-21-2003 at 11:07 AM.

  2. #2
    train spotter
    Join Date
    Aug 2001
    near a computer
    File IO is slow but if the file is not large compared to the read size, it should not be a problem.

    I prefer to grenerally

    find the file size,
    alloc a buffer,
    read entire file,
    close file,
    process data,
    free mem.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    For windows, lookup the functions


    I believe those are the functions
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  4. #4
    Join Date
    Sep 2003
    novacain >
    Thanks, I think I can do it that way.

    neandrake >
    I already know the functions. ^^ Just posted the question here because maybe I could get some platform specific stuffs but, don't seem to. Thanks anyway.

  5. #5
    Registered User
    Join Date
    Oct 2003
    try file mapping

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM