We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,521 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Getting the stream of the file to which output is redirected.

How can we know the name of the stream to which output is being redirected through a C++ program?
For example, I have a program 1.cpp whose output is being redirected to a file a.txt
i.e., a.out > a.txt
Now, I want to know the name of the file to which output is being redirected in the program itself.
How can I do that?

Thanks in advance.

2
Contributors
1
Reply
39 Minutes
Discussion Span
8 Months Ago
Last Updated
2
Views
rtyui
Newbie Poster
2 posts since Sep 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

No. Redirection, piping and general screen printing are facilities of the OS, not your program. Additionally, there are other tools, such as tee which would complicate the matter if you could. Suppose you had ./a.out | tee a.txt would you want that tee was receiving your output or that it was ultimately sent to a.txt?

L7Sqr
Practically a Posting Shark
866 posts since Feb 2011
Reputation Points: 253
Solved Threads: 155
Skill Endorsements: 7

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0544 seconds using 2.66MB