Thread: Eof

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    153

    Eof

    Hello again, it's your friendly neighborhood Chap,
    I was curious what are the uses for determining the end of file in user input? What practical uses for it are there? Just something that was on my mind...also is cout.put() used often? that's just been on my mind...Thanks yet again! -Chap

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    As for user input (Im assuming you mean from a console), EOF is just a way to terminate the input. You could just as easily terminate at a newline character, or some other preset value. An example of this can be found at Bjarn's Technical FAQ .

    The main problem with using EOF that I can think of is that the windows console is bugged, and doesn't recognize the EOF character (not sure if this have been fixed). On linux, you send EOF to the console using ctrl-D.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> I was curious what are the uses for determining the end of file in user input? What practical uses for it are there?

    it can be quite useful at preventing infinite loops. seriously though, how else would you know when to stop?? if you're referring to EOF with respect to the standard input, often you'll see other methods for determining an 'end of input' condition not normally used with other input streams, but EOF is still just as applicable nonetheless.

    >> ...also is cout.put() used often? that's just been on my mind...

    sure.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I was curious what are the uses for determining the end of file in user input?
    It's not considered valid input and it's a convenient input termination method. What more do you need?

    >also is cout.put() used often?
    I can't speak for everyone else, but I use it often when the output is a single character.
    My best code is written with the delete key.

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Did you know you can terminate a Linux shell by pressing Ctrl+D? That's because the shell checks for EOF even in normal user input. Very useful.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

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