I want to switch between writing to the file and to the stdout
I can't use fprintf
, but only printf
and freopen
something like this:
for(size_t i;i<100;++i)
{
if(i%2)
{
freopen("tmp","w",stdout);
printf("%d\n",i);
}
else
{
//return to write to stdout?
printf("%d\n",i);
}
}
How can I return to writing to the stdout
?
Update
I write cross-platform application and dup
can't be used.