I'm trying to (as the title says) read from a file into main, using argc and argv, taking the filename from the command line and passing it through main into a void function which opens, reads and writes it. However im getting Cannot open file...
Segmentation fault
.
void file_pass (char * argv[])
{
FILE *file_name;
if ((file_name = fopen(argv[1], "r")) == NULL)
{
printf("Cannot open file ...\n");
}
fclose(file_name);
}
Which leads me to think it isn't opening the file correctly but I'm not sure why.