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



"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


.