Below is a piece of the code from copy.c in pset4. I am interpreting it in the following way:
the name of the input file is being entered as a string to be stored at argv[1].
a pointer to argv[1][0] is declared (char* infile)
the pointer 'infile' is passed to fopen().
Does fopen read through all of argv[1] until it encounters an implicit NULL terminator (\0)? Otherwise how does it know what the entire name of the file is? Is this how functions typically behave when passed an array (do they read through the array until encountering a '/0'?)
int main(int argc, char* argv[])
{
// ensure proper usage
if (argc != 3)
{
printf("Usage: ./copy infile outfile\n");
return 1;
}
// remember filenames
char* infile = argv[1];
char* outfile = argv[2];
// open input file
FILE* inptr = fopen(infile, "r");
...
}