Fopen won't open in C successfully, and I'm on the linux platform using the gcc compiler. It's the unconfigured C compiler on linux. What I would like to do is open a simple text file in read only mode, but the fopen function failed. Here's the source code:
Quote:
FILE *ifp = fopen("input.txt", "r");
fgets(buf, 1024, ifp);
if(ifp == NULL) {
fprintf(ifp, "can't fopen file: %s", buf);
}
fputs(buf, ifp);
fscanf(ifp, "%s", buf);
fprintf(ifp, "%s\n", buf);
fclose(ifp);
return EXIT_SUCCESS;