C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

redirection of cin/cout

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Ralf Goertz
Guest





PostPosted: Fri Nov 24, 2006 10:11 am    Post subject: redirection of cin/cout Reply with quote



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





PostPosted: Fri Nov 24, 2006 10:11 am    Post subject: Re: redirection of cin/cout Reply with quote



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





PostPosted: Mon Nov 27, 2006 10:10 am    Post subject: Re: redirection of cin/cout Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.