Thread: reading from stdin

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You should be able to do this using "select()", perhaps something like this:
    Code:
    bool checkifdata(FILE *f)
    {
       int fno = fileno(f);
       fd_set fdset;
       FD_ZERO(fdset);
       FD_SET(fno, fdset);
       
       return select(fno+1, fdset, NULL, NULL, NULL);
    }
    Sorry if this is a late reply, but I got sidetracked.

    --
    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.

  2. #2
    coder
    Join Date
    Feb 2008
    Posts
    127
    Quote Originally Posted by King Mir
    It says that in_avail calls showmanyc(). That function can check if underflow is possible, and return the number of available characters. However there is no requirement that cin implements this functionality; the default behavior is simply to return 0.
    Ok thanks, I don't know what "underflow" means exactly, but I figured out what the matter is.

    -----------------------------
    select() seems to be the right way, checking it out...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking stdin for input
    By hawaiian robots in forum C Programming
    Replies: 7
    Last Post: 05-19-2009, 09:06 AM
  2. stdin + (ctrl+z), how i detect it?
    By Olimpo in forum C Programming
    Replies: 1
    Last Post: 09-30-2006, 05:33 AM
  3. reading from stdin
    By AngKar in forum C Programming
    Replies: 4
    Last Post: 05-03-2006, 12:14 PM
  4. Fun with reading hex
    By dpro in forum C++ Programming
    Replies: 7
    Last Post: 02-17-2006, 06:41 PM
  5. Array, reading in response etc...
    By mattz in forum C Programming
    Replies: 4
    Last Post: 12-05-2001, 11:41 AM