defaulting ifstream variable to standard input

This is a discussion on defaulting ifstream variable to standard input within the C++ Programming forums, part of the General Programming Boards category; But remember that you're supposed to switch the buffer back before destructing the stream....

  1. #16
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    But remember that you're supposed to switch the buffer back before destructing the stream.
    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

  2. #17
    Registered User
    Join Date
    Apr 2006
    Posts
    2,027
    Quote Originally Posted by risby View Post
    That looks good. I've tried it and it works fine with stdin but fails to read anything from a file. I'll play around with it though, thanks.
    As I had written it, I had the wrong condition on the if statement. It should be if(inputStream).
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Input class project (again)
    By Elysia in forum C++ Programming
    Replies: 41
    Last Post: 02-13-2009, 09:52 AM
  2. Writing a Variable as a string input to a function
    By gaza2k1 in forum C++ Programming
    Replies: 4
    Last Post: 11-29-2007, 12:04 PM
  3. Outputting to a File Modified Text
    By alpha in forum C++ Programming
    Replies: 8
    Last Post: 11-24-2003, 07:39 PM
  4. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 01:45 PM
  5. Variable Allocation in a simple operating system
    By awkeller in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 01:26 PM

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