open_cls.c

来自「c和指针 学习c语言必须阅读的书籍之一 提高对C语言的掌握理解能力」· C语言 代码 · 共 42 行

C
42
字号
/*
** Process each of the files whose names appear on the command line.
*/
#include <stdlib.h>
#include <stdio.h>

int
main( int ac, char **av )
{
	int	exit_status = EXIT_SUCCESS;
	FILE	*input;

	/*
	** While there are more names ...
	*/
	while( *++av != NULL ){
		/*
		** Try opening the file.
		*/
		input = fopen( *av, "r" );
		if( input == NULL ){
			perror( *av );
			exit_status = EXIT_FAILURE;
			continue;
		}

		/*
		** Process the file here ...
		*/

		/*
		** Close the file (don't expect any errors here).
		*/
		if( fclose( input ) != 0 ){
			perror( "fclose" );
			exit( EXIT_FAILURE );
		}
	}

	return exit_status;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?