title: Redirecting standard I/O: freopen + stdin/stdout vs open + dup2
body: <p>I want to redirect stdin/stdout to some file. The program is being written for Unix OS but I think using standart C/C++ library instead of OS functions is good. I know how I can do that using OS functions <code>dup2()</code> and <code>open()</code> but I read some ways to do that using <code>reopen()</code> on <code>stdin</code> or <code>stdout</code>. Will reopening standart variables do what I want? Will it replace files opened at 0 and 1 file descriptors? Which way is better?</p>