/** ** 0 stdin scanf() cin System.in ** 1 stdout printf() cout System.out ** 2 stderr fprintf() cerr System.err **/ #include #include #include #include #include #include extern int errno; int main( int argc, char *argv[] ) { if ( argc != 2 ) { fprintf( stderr, "ERROR: Invalid usage.\n" ); fprintf( stderr, "USAGE: %s \n", argv[0] ); return EXIT_FAILURE; } printf( "Processing file %s....\n", argv[1] ); int rc = open( argv[1], O_RDONLY ); if ( rc < 0 ) { fprintf( stderr, "ERROR: errno is %d\n", errno ); perror( "error opening file" ); return EXIT_FAILURE; } return EXIT_SUCCESS; }