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:
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..
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)
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)
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)
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)
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)
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)
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)
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)
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)