fgetc - returns immediately?

This is a discussion on fgetc - returns immediately? within the C Programming forums, part of the General Programming Boards category; Does anyone really familiar with the standard (yes, that means you, quzah) know if fgetc will return immediately. On MSDN ...

  1. #1
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913

    fgetc - returns immediately?

    Does anyone really familiar with the standard (yes, that means you, quzah) know if fgetc will return immediately. On MSDN it said that if the file specified (stdin in my case - still trying to find a way to avoid threads so I can write a version of my program for DOS - I'm using threads in other version, though) was at the end of the file, it would return the EOF signal. So does this mean that if there is no input it will return EOF, and not wait for input.

    I appreciate all the help.

    Sean.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,701
    >> So does this mean that if there is no input it will return EOF, and not wait for input.

    the only way you're going to get an EOF from stdin is if an error occurs or if the user presses CTL-Z. otherwise it's going to block indefinately.
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >does this mean that if there is no input it will return EOF, and not wait for input.
    No, all of the standard input functions cause a blocking read for an interactive stream if there's no input.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 02:27 AM
  2. Polynomials and ADT's
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2008, 08:32 AM
  3. fgetc() skips carriage returns?
    By OnionKnight in forum C Programming
    Replies: 2
    Last Post: 02-02-2006, 09:26 AM
  4. fgetc() and getc()
    By The Dog in forum C Programming
    Replies: 2
    Last Post: 07-24-2002, 05:00 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

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