End of file question

This is a discussion on End of file question within the C++ Programming forums, part of the General Programming Boards category; Is the EOF character specific to the C/C++ language or is it an actual byte at the end of every ...

  1. #1
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640

    End of file question

    Is the EOF character specific to the C/C++ language or is it an actual byte at the end of every file? I need to create a file from an input stream and I'm having difficulties determining then end of the file being sent.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  2. #2

  3. #3
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    man I feel stupid. the one place I haven't checked
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    No worries. I've read that tutorial several times, and I am unable to make any sense of it.
    I need to create a file from an input stream and I'm having difficulties determining then end of the file being sent.
    Code:
    while( getline(inFile, input) )
    {
        //do something with the input
    }
    That while loop will terminate if a stream error occurs that prevents you from reading from the file, or if you hit the end of the file.

    (Any read function that returns an istream& can be used similarly.)
    Last edited by 7stud; 02-24-2006 at 10:55 PM.

  5. #5
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    Thanks 7stud, except the stream I am using is sockets, and just by thinking it through I don't think there's any way to do that with recieving. I think the only way is to use specific protocol's file transfer methods.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 12-06-2008, 01:43 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. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  4. File I/O Question
    By Achy in forum C Programming
    Replies: 2
    Last Post: 11-17-2005, 11:09 PM
  5. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM

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