The main function that opens the file is located in "project" directory. Then I have a "cmake-build-bug" directory( located in "project" directory) where is "data.txt" file located. I want to read it, but for some reason it keeps wrinting Error to open file
. I never understand how to write the correct path to the file. Or is there another problem that gives the error?
FILE *file[2] ;
char *fileName2 = "data.txt";
file[1] = fopen(fileName2, "r");
if (file[1] == NULL){
printf("Error to open file
");
}
printf("Reading..
");
fclose(file[1]);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…