Sponsored Content
Top Forums Programming std::cout and gfortran print*, don't output to the screen Post 302509004 by Corona688 on Tuesday 29th of March 2011 02:58:52 PM
Old 03-29-2011
Bronchitis is no fun. Smilie Get well soon.

Thank you, now we finally know what you want.

Flushing shouldn't matter, anything still in the buffers will be printed before the program exits -- unless your program crashes or is killed by a signal. In that case buffers won't be flushed.

It's probably a better idea to print debug messages to stderr or cerr in general. They never buffer, and won't get mixed in with any data you were expecting on stdout/cout.

If you're using cin/cout/cerr, you should stick to cin/cout/cerr and not use stdin/stdout/stderr. Or vice versa. They compete for the same resources and could conceivably cause each other problems.

If your program isn't crashing and you're not mixing stdio+iostreams and you're still not getting output, something must be closing or redirecting these streams or file descriptors. Try putting this into your program somewhere:
Code:
system("ls -l /proc/self/fd > /path/to/files.txt");

which should print a list of what files and terminals and sockets your application has open into /path/to/files.txt

Last edited by Corona688; 03-29-2011 at 04:10 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to redirect std out and std err to same file

Hi I want both standard output and standard error of my command cmd to go to the same file log.txt. please let me know the best commandline to do this. Thanks (2 Replies)
Discussion started by: 0ktalmagik
2 Replies

2. Programming

Why I don't get any output?

Hello, I am very new in writing low level programming in C. I am trying to get an output in Linux 2.6.17.6 gentoo platform, but I don't get any output. I am trying to do the following: I am trying to scan a word and print its content at the standard output by using sscanf and printf. I... (6 Replies)
Discussion started by: Sharmin
6 Replies

3. Programming

Sun Studio C++ - Getting error in linking std::ostream &std::ostream::operator<<(std:

Hello all Im using CC: Sun C++ 5.6 2004/07/15 and using the -library=stlport4 when linkning im getting The fallowing error : Undefined first referenced symbol in file std::ostream &std::ostream::operator<<(std::ios_base&(*)(std::ios_base&))... (0 Replies)
Discussion started by: umen
0 Replies

4. Shell Programming and Scripting

awk to compare lines of two files and print output on screen

hey guys, I have two files both with two columns, I have already created an awk code to ignore certain lines (e.g lines that start with 963) as they wou ld begin with a certain string, however, the rest I have added together and calculated the average. At the moment the code also displays... (3 Replies)
Discussion started by: chlfc
3 Replies

5. UNIX for Dummies Questions & Answers

cout doesn't print everything

Hi all, I implemented a C++ program and successfully compiled and ran on my laptop. However when I copy my code to another machine (school's sun machine), it didn't run properly. I can compile and run, but cout does not print everything. I used cout in a loop where it iterates no more than 20... (5 Replies)
Discussion started by: SaTYR
5 Replies

6. AIX

Redirecting Both to a file and std output

Hello Friends, Can some one help me how to redirect output of a file to both a file and std output? All the help would be greatly appreciated. Regards Sridhar (1 Reply)
Discussion started by: send2sridhar
1 Replies

7. UNIX for Advanced & Expert Users

redirect to both file and std output at the same time

hello can some one please help me to redirect the output of a command to both std output and a file. this is little urgent. sridhar (2 Replies)
Discussion started by: send2sridhar
2 Replies

8. UNIX for Dummies Questions & Answers

how to print script output to screen and file

Hi all, I have a script that bulk loads thousands of lines of data. I need to log the output during the execution of the script. I know I can redirect (">") the output to a file; however, I want the output going to both the screen and the log file. I thought I could use pipe to pipe the... (10 Replies)
Discussion started by: orahi001
10 Replies

9. Solaris

Camouflage STD IN on output (TRU64)

Hi guys, i have a new problem, even in scripting on KSH. Given a string by standard INPUT (keyboard), i need to replace each character i print with this one '#' . It's to camouflage password while digiting on command line. For example: ---------------------------------- prompt$ ... (3 Replies)
Discussion started by: D4vid
3 Replies

10. UNIX for Dummies Questions & Answers

awk: don't print sub-arrays

Hi ! I have this input: 12{11}{11110}{80}3456 {123}15{60}9876{8083}34 I try to work on individual numbers between braces. 3 possible cases (here I used colours to be clearer only): - there is no "0" among the characters between braces: so we don't touch anything. - there is a "0" among... (4 Replies)
Discussion started by: beca123456
4 Replies
FBB::MultiStreambuf(3bobcat)				     Writing multiple streams				      FBB::MultiStreambuf(3bobcat)

NAME
FBB::MultiStreambuf - Selectively writes multiple streams SYNOPSIS
#include <bobcat/multistreambuf> Linking option: -lbobcat DESCRIPTION
The FBB::MultiStreambuf class is a specialization of std::streambuf. It can be used to write selectvely to multiple std::ostreams. Each std::ostream that is associated with an FBB::MultiStreambuf is given a mode-tag indicating whether the stream should always be used when information is inserted into the FBB::MultiStreambuf, just once, or not at all. Each of the stream's mode-tags may be set to any of the defined tag-values. When the address of a FBB::MultiStreambuf is used to initialize a std::ostream the constructed std::ostream becomes an output-multiplexer: by inserting information into the std::ostream object, all std::ostream objects added to its FBB::MultiStreambuf buffer which have an active mode will receive that information. An FBB::MultiStreambuf object should be outlived by all active streams that are associated with it. No assumptions should be made about the order in which the std::ostream objects that are associated with the FBB::MultiStreambuf objects are visited when information is inserted. NAMESPACE
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. INHERITS FROM
std::streambuf ENUMERATION
In the Mode enumeration the following values are defined: o OFF: A std::ostream having this mode will not be used when information is inserted into an FBB::MultiStreambuf o ON: A std::ostream having this mode will be used when information is inserted into an FBB::MultiStreambuf o ONCE: A std::ostream having this mode will be used once, until the next flushing operation, when information is inserted into an FBB::Mul- tiStreambuf o RESET: A std::ostream having this mode will not be used when information is inserted into an FBB::MultiStreambuf. At a flush operation all ONCE modes will be set to RESET TYPES
The following subtypes are defined in the class FBB:MultiStreambuf: o iterator: This is a synonym of std::vector<stream>::iterator o const_iterator: This is a synonym of std::vector<stream>::const_iterator NESTED CLASS
The class FBB::MultiStreambuf::stream is defined as a nested class of FBB::MultiStreambuf. It offers the following constructor and public members: o stream(std::ostream &os, Mode mode = ON): The constructor stores a std::ostream object, and associates a Mode value with it. o void setMode(Mode mode): This member is used to redefine the stream's Mode value. o void mode() const: This member returns the stream's Mode value. o operator std::ostream &(): This member returns the stream's std::ostream. CONSTRUCTORS
o MultiStreambuf(): The default constructor creates a FBB::MultiStreambuf object which contains no associated std::ostream objects. o MultiStreambuf(std::ostream &os, Mode mode = ON): This constructor creates a FBB::MultiStreambuf object which is immediately associated with the std::ostream specified as its first argument. o MultiStreambuf(std::vector<MultiStreambuf::stream> const &osvector): This constructor creates a FBB::MultiStreambuf object which is immediately associated with all std::ostream objects that are stored in the MultiStreambuf::stream elements of the specified vector. The copy constructor is available. MEMBER FUNCTIONS
All members of std::ostringstream and std::exception are available, as FBB::MultiStreambuf inherits from these classes. o iterator begin(): This member returns an iterator to the first stream element that is stored in a FBB::MultiStreambuf object. o const_iterator begin(): This member returns an iterator to the first (unmodifiable) stream element that is stored in a FBB::MultiStreambuf object. o iterator end(): This member returns an iterator pointing beyond the last stream element that is stored in a FBB::MultiStreambuf object. o iterator end(): This member returns an iterator pointing beyond the last (unmodifiable) stream element that is stored in a FBB::MultiStreambuf object. o void insert(std::ostream &os, Mode mode = ON): This member adds the specified std::ostream using the specified Mode to the current set of stream objects. o void insert(std::vector<stream> const &os): This member adds all stream objects stored in the os vector to the current set of stream objects. o void void setOnce(): This member will reset all the RESET Mode values of the stored stream objects to ONCE. PROTECTED MEMBER FUNCTION
The member listed in this section implements the tasks of the comparably named virtual function in the class's private interface. This sep- arates the redefinable interface from the user-interface. The class MultiStreamBuf can, in accordance with Liskov's Substitution Principle, be used as a std:streambuf; but it also offers a facility for classes deriving from MultiStreamBuf. This facility is listed here. o int pSync(): The contents of the MultiStreamBuf's internal buffer is written to each of the std::ostream objects to which the MultiStreamBuf object has access. EXAMPLE
#include <iostream> #include <fstream> #include <bobcat/multistreambuf> using namespace std; using namespace FBB; int main() { MultiStreambuf msb(cout); ostream os(&msb); ofstream out("out"); msb.insert(out, MultiStreambuf::ONCE); os << "This is on cout and out" << endl; os << "This is on cout only" << endl; msb.setOnce(); os << "This is on cout and out" << endl; os << "This is on cout only" << endl; return 0; } FILES
bobcat/multistreambuf - defines the class interface SEE ALSO
bobcat(7) BUGS
None Reported. DISTRIBUTION FILES
o bobcat_3.01.00-x.dsc: detached signature; o bobcat_3.01.00-x.tar.gz: source archive; o bobcat_3.01.00-x_i386.changes: change log; o libbobcat1_3.01.00-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location; BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). libbobcat1-dev_3.01.00-x.tar.gz 2005-2012 FBB::MultiStreambuf(3bobcat)
All times are GMT -4. The time now is 06:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy