Re: Why would "fopen(stdin,"rb")" fail?
- From: "David F" <David-White@xxxxxxxxxxxxx>
- Date: Tue, 21 Aug 2007 23:01:56 -0700
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
.
- Follow-Ups:
- Re: Why would "fopen(stdin,"rb")" fail?
- From: Igor Tandetnik
- Re: Why would "fopen(stdin,"rb")" fail?
- References:
- Why would "fopen(stdin,"rb")" fail?
- From: David F
- Re: Why would "fopen(stdin,"rb")" fail?
- From: Igor Tandetnik
- Why would "fopen(stdin,"rb")" fail?
- Prev by Date: Re: fopen and wfopen
- Next by Date: Re: undefined files in project dir
- Previous by thread: Re: Why would "fopen(stdin,"rb")" fail?
- Next by thread: Re: Why would "fopen(stdin,"rb")" fail?
- Index(es):
Relevant Pages
|