I want a way to selectively turn on & off file inputs at compile time without commenting out large portions of code. I thought I could do this:
Code:
FILE* fileout;
if(NoWrite) //NoWrite = 1 means no output
fileout = NULL;
else if((fileout=fopen("put.out","w"))==NULL)
printf("Could not open output file!\n");
fprintf(fileout,"writing to output file\n");
//many more of these, and in other places
fclose(fileout);
but I get access violations, presumably because you can't pass fprintf a NULL pointer. So what else can I do to disable opening & printing of the output file? The program I'm writing needs to operate off a CD without writing any outputs.
Thanks!