fopen() returning a NULL pointer, but the file definitely exists

前端 未结 7 811
不思量自难忘°
不思量自难忘° 2020-12-31 02:25

The code I have is as follows:

FILE *txt_file = fopen(\"data.txt\", \"r\");
if (txt_file == NULL) {
    perror(\"Can\'t open file\");
} 

Th

7条回答
  •  失恋的感觉
    2020-12-31 03:01

    My problem was that I had a file filename.txt and I didn't realize that in reality it was filename.txt.txt due to windows not showing the extension.

提交回复
热议问题