fopen() and CON

Andre Oliveira da Costa
Fri Dec 10 12:26:00 GMT 1999


I'm writing a program in which I have to open (literally) thousands of
files, each with its own name (there are no duplicated names). One of them,
to my deepest sorrow, is named CON.html, which leads to this situation:
fopen("CON.html", "w") returns a valid (not NULL) pointer, _different from
stdout or stderr_. However, every output I redirect to this file (with
fprintf()) is actually redirected to the terminal. It took me a _long_ time
to remember that, under MS-DOS, CON is associated to the terminal. Now,
things are clearer, but still some doubts remain:

* should the CON device had been opened if I asked for CON.html?
* is there any way to avoid this? (I mean, what I really want is to have a
text file named CON.html)

I'm using B20.1 with snapshot 19991122 on top of it, and gcc-2.95.2.


André Oliveira da Costa

BTW: Before someone asks: each file is closed before the next is opened, so
I don't run into any limit of opened files.

Want to unsubscribe from this list?
Send a message to

More information about the Cygwin mailing list