_____main function contains two parameters, ARGC, argv[]
These two parameters are used to indicate the parameter information entered by the command line.
The value of the ARGC is the number of input parameters. ARGV is an array in which each array element points to the address of a string type of data, that is, the address of each input parameter. ARGV is a char * * type.
voidFileCopy (FILE *ifp,file *OFP) { intC; while((c = getc (IFP))! =EOF) {PUTC (C,OFP); }}intMainintargcChar*argv[]) { //Practice file Access//practice argc, argvFILE *FP; if(ARGC = =1)//no args;copy standard input{fileCopy (stdin, stdout); } Else{printf ("%d\n", ARGC); while(--ARGC >0) { inti; 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 corresponds to the standard input and output of printf and scanf, the parameter is more than the first one of the file type parameters.
File type
File access, argc, argv[]