Thread: file reading

  1. #1
    Unregistered
    Guest

    file reading

    I have a problem using ifstream to read files. It works fine for reading smaller files up to 1mb but when i start reading larger ones of around 5 mb it doesnt read the whole file. It stops reading in the begining of the file.
    This is what i do:

    ifstream fin("C:/TEST.TXT");
    if(!fin){
    cerr<<"\nFile could not be opened!";
    getch();
    exit(1);
    }

    char ch;

    do{
    fin.get(ch);
    //some other code
    }while(!fin.eof());

    fin.close();

    Do you see the problem?

  2. #2
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330
    For file-input, I generally use strings rather than char =]

  3. #3
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    ifstream fin("C:/TEST.TXT");

    is it compiling??

    i have to do

    ifstream fin("C:\\TEST.TXT");
    -

  4. #4
    Unregistered
    Guest
    I have already tried using strings but i still come across the same problem.

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