EOF while scanning

This is a discussion on EOF while scanning within the C++ Programming forums, part of the General Programming Boards category; hi. i wud like to scan the inputs until EOF ...how would i do that...

  1. #1
    dpp
    dpp is offline
    Registered User
    Join Date
    Jan 2009
    Posts
    197

    EOF while scanning

    hi. i wud like to scan the inputs until EOF ...how would i do that

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    On the assumption that "scan the inputs" means something, you would do ... whatever it is you intend to do ... until it fails. (Technically, it could fail for other reasons, like bad input, but you can check afterwards whether .eof is true.)

  3. #3
    dpp
    dpp is offline
    Registered User
    Join Date
    Jan 2009
    Posts
    197
    ignore the cases for bad input...i just need to identify end of input

    untlii end of input

    cin>>x;

    should i do
    while(.eof==true)
    cin>>x;

  4. #4
    dpp
    dpp is offline
    Registered User
    Join Date
    Jan 2009
    Posts
    197
    let me have the code to do it

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You need to read while the read is good. So while (cin >> x).

  6. #6
    dpp
    dpp is offline
    Registered User
    Join Date
    Jan 2009
    Posts
    197
    it doesnt work
    fine do u know wat does rawinput()[-1] in python do...tat ll solve me the prob..
    if yes i shud be able to do in c++

  7. #7
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    As a matter of fact, it (the while statement, I mean) does in fact work. You are typing EOF yourself with Ctrl-Z on Windows/Ctrl-D on *nix, yes? If you just want one line, that's something else. (Edit: You may have to press enter after EOF, of course, if you are typing this yourself.)
    Last edited by tabstop; 01-23-2009 at 09:16 PM.

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, 08: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, 03: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

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