I have a function that should be able to write either to stdout or to a file, depending on what the user wants. However, it is default by default. To do this, I do the following (minus error checking, etc.):
FILE* out; if (writeToFile) { ; } else out = stdout;
This, of course, is a trick, but I have no idea how portable it is. And if it is not, and / or there is another problem with this, how can I do it?
source share