Re: Why would "fopen(stdin,"rb")" fail?

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thanks.
-kbhit is exactly what I needed but is not a standard
and even requires .NET 2.0+ (for VC++2005).
Is there no similar functionality that can be accomplished using
ISO C\C++?
I played with cin.peek() and seems that it also not returning an
indication whether there is a char in input buffer.

David

"Igor Tandetnik" <itandetnik@xxxxxxxx> wrote in message
news:uqqovf64HHA.2108@xxxxxxxxxxxxxxxxxxxxxxx
"David F" <David-White@xxxxxxxxxxxxx> wrote in message
news:%23XdsmP64HHA.1164@xxxxxxxxxxxxxxxxxxxx
I am doing the following:

fclose(stdin);
FILE* fp=fopen(stdin,"rb");

The compiler complains as follows:
error C2664: 'fopen' : cannot convert parameter 1 from 'FILE *__w64 '
to 'const char *'

What else did you expect?

Since it has no complain about the fclose(), why would it complain
about fopen?

Because fclose takes a FILE* (a handle to a file), while fopen takes a
char* (a file name).

My purpose is to check the input queue from keyboard, w/o waiting for
the user

See _kbhit, _getch
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925




.



Relevant Pages

  • Re: Get ASCII value for character when higher than 127
    ... the C++ standard ... has no requirement as the signedness of char. ... ISO defines ASCII which is in range 0x01 - 0x7f. ...
    (microsoft.public.vc.language)
  • Re: Destructor: not gauranteed to be called?
    ... >>> the ToStringmethod to a Char[] it returns with the EXACT SAME ... >>> the standard and might break someone's existing code. ... ToString is not part of the C++ ... The fact yhat you require or expect a Charto act as a string is a sign ...
    (microsoft.public.dotnet.languages.vc)
  • Re: byte order
    ... int am_i_little_endian{ ... Are you *absolutely* sure that's standard C, ... assuming a 8-bit char). ... The pointer casting rules specify that "It is guaranteed that ...
    (comp.lang.lisp)
  • Re: An Observation
    ... You execute it now or you execute it later. ... I explained CHAR and as I did in my prior post in ... complexity around and was not actually any simpler. ... because of the sloppiness of the standard. ...
    (comp.lang.forth)
  • Re: I want unsigned char * string literals
    ... within the text one should cast to unsigned char first. ... The original Standard tried to codify ... useless at this point. ... locale - no context object so it can't be safely used in libraries ...
    (comp.lang.c)