Hey,
I was wondering: If I use "fclose(stdin)" to deactivate keyboard input, how can I "reopen" stdin? I believe it has to do with fdopen().....?
Hey,
I was wondering: If I use "fclose(stdin)" to deactivate keyboard input, how can I "reopen" stdin? I believe it has to do with fdopen().....?
Last edited by B-Con; 05-30-2004 at 06:58 PM.
"Cryptographically secure linear feedback shift register based stream ciphers" -- a phrase that'll get any party started.
dup:Code:#include <stdio.h> int main(void) { int standard_input; standard_input = dup(STDIN_FILENO); fclose(stdin); fdopen(standard_input, "r"); return 0; }
http://www.rt.com/man/dup.2.html
fdopen:
http://www.neosoft.com/neosoft/man/fdopen.3.html
Help populate a c/c++ help irc channel
server: irc://irc.efnet.net
channel: #c
Do you ever take the time to try and research your questions C+++C_forever? Since these functions reside in stdio.h its a pretty good possiblity that they are standard.
I get it now..... Much thanx
"Cryptographically secure linear feedback shift register based stream ciphers" -- a phrase that'll get any party started.
The following are not standard:
dup
fdopen
and the macro STDIN_FILENO
In ISO C, you interact with files through objects of type FILE *, there are no functions involving file descriptors, file handles etc.
The one who says it cannot be done should never interrupt the one who is doing it.
Do you ever take time to research your answers, Thantos? If you had even glanced at the links provided, you would've realized that the dup() and fdopen() functions are not ANSI-compliant, but POSIX-compliant.Originally Posted by Thantos
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
I looked up fdopen() on the man page andwas tired and didn't realize that it didn't say fdopen(). Sorry was tiredThe fopen and freopen functions conform to ANSI X3.159-1989 (``ANSI C'').