Thread: Eof

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    58

    Eof

    ok i know this has been posted before but search wont let my search for eof (or ENd Of File) anyway i need to know when im using ifstream somename(somefile) how to go untill EOF it's been a while for me and this is what i can remember help me out here


    ifstream somename(somefile);

    while(!somename.eof())
    {
    somecommands
    }
    that gives an error what am i doing wrong?

  2. #2
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    gotta see code...

    are you putting " " quotes around your file name?
    Blue

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    58
    the problem is the EOF statment it dosnt like that im actually using a string for the filename but it finds it none the less.
    --== www.NuclearWasteSite.com==--

  4. #4
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    no... but eof will only work if the file has been opened.

    try

    ...

    ifstream somename(somefile);
    if (somename.fail())
    {
    cout << "Yep... it failed.\n";
    return 1;
    }
    ...
    Blue

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    58
    i got it to work, stupid me you cant capitolize EOF i was doing this

    while(!somefile.EOF())

    gotta do this
    while(!somefile.eof())
    --== www.NuclearWasteSite.com==--

  6. #6
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    ah... I see...

    happens all the time.
    Blue

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. EOF Explanation Anybody?
    By blackcell in forum C Programming
    Replies: 1
    Last Post: 01-29-2008, 09:09 PM
  2. EOF or not EOF?
    By CornedBee in forum Linux Programming
    Replies: 2
    Last Post: 09-14-2007, 02:25 PM
  3. EOF messing up my input stream?
    By Decrypt in forum C++ Programming
    Replies: 4
    Last Post: 09-30-2005, 03:00 PM
  4. whats the deal with EOF really ???
    By gemini_shooter in forum C Programming
    Replies: 7
    Last Post: 03-06-2005, 04:04 PM
  5. files won't stop being read!!!
    By jverkoey in forum C++ Programming
    Replies: 15
    Last Post: 04-10-2003, 05:28 AM