Thread: Need some information on basic stuff

  1. #1
    Registered User Sshakey6791's Avatar
    Join Date
    Nov 2008
    Location
    -
    Posts
    57

    Question Need some information on basic stuff

    What is the input buffer?
    What is the different between flash() and ignore() and get()?
    How do they relate?

    I really sorry for these basic question but I'm really into C++ and I just trying to learn everything I can. I looked around and can't find anything.

    Thanks
    "Blood you have thirsted for -- now, drink your own!"
    (Dante)

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I suppose you mean flush - which in computer terms usually means "make sure any output is actually outputted, rather than in some internal buffer".

    The input buffer is an area of memory used to store input before it's been used up. This is so that when you are typing in something, it is possible to press the back-space button (or some such) to correct what you've been typing before you hit enter. When you hit enter, all the data up until the "enter" is in the input buffer. Functions that read data will then "use" one character at a time from the input buffer - for example, reading a number will stop when you get to the first non-numeric input. Next read operation will start from whereever the last one ended.

    istream::get()
    istream::ignore()
    ostream::flush().

    Note that some people, incorrectly, use the C function fflush() to clear the input buffer - this is not specified in the standard [1], but some C-libraries do support it.

    [1] Not specified means that it is undefined behaviour, which in turn means that "it may do anything" - if you use fflush() on an input file, it can: clear the input buffer, do nothing, draw green text on the screen or crash the application - all are "within the specification" according to the stanrdard, as the standard does not say anything about what happens when you do that, it only states that it should work for OUTPUT files.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 06-01-2009, 07:54 PM
  2. what are your thoughts on visual basic?
    By orion- in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-22-2005, 04:28 AM
  3. visual basic vs C or C++
    By FOOTOO in forum Windows Programming
    Replies: 5
    Last Post: 02-06-2005, 08:41 PM
  4. Id3dxsprite Basic
    By andyhunter in forum Game Programming
    Replies: 6
    Last Post: 12-21-2004, 02:01 PM
  5. arrays and validation (basic stuff)
    By Fountain in forum C++ Programming
    Replies: 2
    Last Post: 12-21-2001, 04:25 PM