The first is a source program: #include
INT main (int Argc, char * argv []) {char * s; file * stream; int 1; if (argc <2) {printf ("use 2 para! / n"); exit (0);} stream = FOPEN (Argv [1], "R"); // stream = fopen ("/ TMP / FWRITE", "R"); FREAD (S, 1024, 1, Stream); Fclose (stream); //printf ("Argc IS% D / N", ARGC); Printf ("% S / N", S); exit (0);} The first parameter is the first address of the buffer read, the second parameter is The size of the data block read at a time, the third parameter is the number of read data blocks, and the fourth parameter is the file pointer returned by FOPEN. It implements read data blocks in a "block". Use of main parameters: int Main (int Argc, char * argv [])
The first parameter is the total number of parameters including the program name, and counts from 1. The second parameter is the array of input programs to Argv's array. The shell reads this string, then divides it into a few small characters according to spaces and single quotes, and stores in the Argv in order, and then attached to the main function together with the total number of parameters. Such examples below: The parameters obtained by MyApp Up Down 'and Middle'main are as follows: argc: 4argv: {"myapp", "up", "down", "and middle"} This, Argv [0] [0] The first letter of the first parameter. Argv [1] [0] shows the first letter of the second parameter.