I am a complete noob for C, and I was wondering why, if I take user input, why it wonβt find the file, but when I use it with hard code:
const char * fn = "/Users/james/Documents/test.rtf";
Does everything seem to be okay?
char text[100]; fputs("File location: ", stdout); fflush(stdout); fgets(text, sizeof text, stdin); FILE *fp = fopen(text,"r"); if( fp ) { printf("\nFile Exists"); fclose(fp); } else { printf("\nFiles doesn't exist"); }
Any help would be awesome or just a point for some online source that I obviously could not find. :)
James source share