| View previous topic :: View next topic |
| Author |
Message |
Ralf Goertz Guest
|
Posted: Fri Nov 24, 2006 10:11 am Post subject: redirection of cin/cout |
|
|
Hi,
is there a way to find out whether cin and cout are connected to the
console or to real files or pipes?
Ralf |
|
| Back to top |
|
 |
Ondra Holub Guest
|
Posted: Fri Nov 24, 2006 10:11 am Post subject: Re: redirection of cin/cout |
|
|
| Quote: | is there a way to find out whether cin and cout are connected to the
console or to real files or pipes?
|
In standard C/C++ no.
On Unix you can use isatty() function. On Windows or other systems I do
not know. |
|
| Back to top |
|
 |
Ralf Goertz Guest
|
Posted: Mon Nov 27, 2006 10:10 am Post subject: Re: redirection of cin/cout |
|
|
Ondra Holub wrote:
| Quote: | is there a way to find out whether cin and cout are connected to the
console or to real files or pipes?
In standard C/C++ no.
On Unix you can use isatty() function. On Windows or other systems I
do not know.
|
Thanks. Your response made me come up with an idea myself, I could just
as easily use the /proc filesystem. Then I even get the filenames.
By the way, I asked in the gcc libstdc++ mailing list about the imbue
problem. They told me it was a feature not to use the encoding part of
the locale string since wcin/wcout are synced with stdin/stdout. Thus,
calling std::ios::sync_with_stdio(false) first solves the problem.
Ralf |
|
| Back to top |
|
 |
|