Thread: What is the value of EOF?

  1. #1
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    What is the value of EOF?

    Hello,
    My question is this " getchar() returns a null value when it detects an EOF mark, right or wrong? WHY?
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Straight from the manual
    The getchar() function returns the next character from the input stream pointed to by stdin. If the stream is at end-of-file, the end-of-file indicator is set, and getchar() returns EOF. If a read error occurs, the error indicator is set, and getchar() returns EOF. When an error has occurred, errno contains a value that indicates the type of error that has been detected.
    The value of EOF is (normally) -1.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    No. They return EOF if they detect EOF. EOF is going to be outside the range of normal characters. IIRC, it will always fall outside the range of whatever you are trying to read. It is a unique value that specificly denotes EOF.

    getchar

    [edit]Hammer beat me to it.[/edit]

    Quzah.
    Hope is the first step on the road to disappointment.

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