[Peter Samuelson] > I _am_ rather curious whether, on Windows, using "CON:" for prompting > actually allows stdin to be usable for other things. Like, when > piping or redirecting to it. I suppose I can try to test this > feature using MingW32 + Wine
Hmmm, fopen("CON:", "r+") in mingw32 + Wine just returns a "no such file or directory" error. Not quite what I was hoping for. I'm attaching my test program, maybe someone can test it on Windows.... Peter
#include <stdio.h> #include <stdlib.h> #ifdef WIN32 #define TTY_DEVICE "con:" #else #define TTY_DEVICE "/dev/tty" #endif int main(void) { FILE *fp; char buf[1024]; fp = fopen(TTY_DEVICE, "r+"); if (!fp) { perror("Cannot open console"); exit(1); } fprintf(fp, "Prompt: "); fflush(fp); if (!fgets(buf, 1024, fp)) { perror("Cannot read from console"); exit(1); } fprintf(fp, "Console input was: %s", buf); while (fgets(buf, 1024, stdin)) { fprintf(stdout, "stdin: %s", buf); } exit(0); }