I run a
$ myprogram.exe
which main function signature is int main(int argc, char *argv[])
The program gets one argument as a directory path, and makes some processing to the files in it.
During the processing it prints some results to stdout (or stderr).
I wanted to redirect these results to the file. So I run my program as follow:
$ myprogram.exe C:\dir > res.txt
The results are still printed to the screen and res.txt remains empty.
How can I solve the issue?
Your program probably prints results to standard error stream (
stderr), rather than standard output stream (stdout).To redirect
stderr, (which is file descriptor2), useIf you want to redirect both
stdoutandstderr, you should redirect them to different files, likeor redirect one stream to the other and redirect latter to file