redirection of cin/cout

R

Ralf Goertz

Hi,

is there a way to find out whether cin and cout are connected to the
console or to real files or pipes?

Ralf
 
O

Ondra Holub

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.
 
R

Ralf Goertz

Ondra said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top