Given something like the following
Code:
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
FILE *fp;
int c1,
char c2;
if ( ( fp = fopen( "test.txt", "r" ) == NULL )
{
fprintf( stderr, "Failed to open file\n" );
return EXIT_FAILURE;
}
/* Read until nothing can be read anymore */
while ( ( c1 = fgetc( fp ) ) != EOF )
putchar( c1 );
#if 0
/* or, when using fscanf() */
while ( fscanf( fp, "%c", &c2 ) == 1 )
putc( c2 )
/* or, when using fread() */
while ( fread( &c2, 1, 1, fp ) == 1 )
putc( c2 )
#endif
/* Check why the last read failed */
if ( feof( fp ) )
fprintf( stderr, "End of file detected\n" );
else
fprintf( stderr, "Read error\n" );
#if 0
/* or using ferror() */
if ( ferror( fp ) )
fprintf( stderr, "Read error\n" );
else
fprintf( stderr, "End of file detected\n" );
#endif
close( fp );
return 0;
}
Is there a particular advantage to suppressing the compilation a block of code vs suppressing the execution of the block ?