I've ran into this problem before while learning C, but I'm trying to solve a problem on Project Euler(no surprise) that requires the user to open a file and read data off. I haven't wrote an algorithm on how to solve it, but the problem is that somehow, I can't open a file using fopen or write to a file. So far I have this code to simply try to open the file:
I tried to even add the txt file to the workspace, but to no success. The file is with the directory and I'm writing the actual project on a USB drive. The question is what's going on and why doesn't it work?
Code:
#include <stdio.h>
int main (int argc, const char * argv[])
{
FILE *list;
list = fopen("roman.txt", "r");
if(list==NULL)
{
printf("Error! Can't find file!\n");
return 1;
}
}
I tried to even add the txt file to the workspace, but to no success. The file is with the directory and I'm writing the actual project on a USB drive. The question is what's going on and why doesn't it work?
Last edited: