好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

file access , argc, argv[ ]

fileCopy(FILE *ifp,FILE * ofp) { int c; while ( (c = getc(ifp) ) != EOF) { putc(c,ofp); } } int main( int argc, char * argv[]) { // practice file access // practice argc, argv FILE * fp; if (argc == 1 ) // no args;copy standard input { fileCopy(stdin, stdout); } else { printf( " %d\n " ,argc); while (--argc > 0 ) { int i; for (i = 0 ; i < argc; i++ ) //parameter is a string. { printf( " %s%s " ,argv[i],(i < argc - 1 ) ? " " : "" ); } printf( " \n " ); /* when parameter is a file name. if( (fp = fopen(*++argv,"r")) == NULL) { printf("can‘t open %s\n", *argv); return 1; } else { fileCopy(fp,stdout); fclose(fp); } */ } } return 0 ; }

___file access

fprintf, fscanf 对应于标准输入输出的printf和scanf,参数多了最前面的一个FILE类型的参数。

FILE类型

 

file access , argc, argv[ ]

标签:

查看更多关于file access , argc, argv[ ]的详细内容...

  阅读:22次