hi guys! pretty new here, just wanted to ask if someone can save me another 5hrs of research - what could cause segmentation fault while i open a file?
ps: it is in the same directory, and i tried entering whole path while starting program,.. nothing helps
thank you A LOT
here is the code:
Code:
int main(int argc, char *argv[])
{
char *file_name = argv[1];
if (argc != 2) {
printf("Usage: ./a4 %s\n", file_name);
return 1;
}
FILE *config_file = fopen(argv[1], "r");
if (config_file == NULL) {
printf("Error: Cannot open file: %s\n", file_name);
return 2;
}
printf("opened");
fclose(config_file);
return 0;
}