I searched the forum and cannot find the answer to this problem. This seems common, but none of the fixes mentioned apply.
This is my code to open the file:
#include <stdio.h> #include <string.h> void main() { FILE *input; char path[200]; printf("Enter the full file path and file name in the following format:" "\nC:\\Users\\Username\\etc......\\filename.extension\n"); fgets(path, 200, stdin); printf("%s",path); input=fopen(path,"r"); if (input==NULL) { perror("The following errors were encountered"); return(-1); } }
printf(%s,path) correctly displays the path and file name I want to open, but fopen always returns an invalid argument. I also tried using the path pointer in fopen, but this always causes the program to crash.
source share