Hello,
I wrote a program which does something like
Code:
while(i<100)
{
 printf(some_message_indicating_what_system_command_I'mdoing);
 system(some system command);
 printf("\n");
}
When I do ./a.out > log.txt, I find that all my printf's are at the bottom of the file, and all the system command outputs are at the top of the file. I would like to have them in sequential order so that I can know which system command is called when comparing outputs.

Please advise.
Thanks.

PS : Consider I'm printing the ls output of dir1, dir2, etc, upto dir100 in a loop. As of now, I get an output something like(see below). So this doesn't tell me which dir contains which files.

-----------------------------------
file.txt
hello.txt
..
..
upto dir100 contents



printing dir1 contents
printing dir2 contents
printing dir3 contents
printing dir100 contents
-----------------------------------