首页 > 解决方案 > 尝试使用带有 WSL 工具链的 CLion 读取文件时遇到问题

问题描述

代码路径为:C:\Users\*****\CLionProjects\bst

文件路径为:C:\Users\*****\CLionProjects\bst\Resources\students

文件内容为:

AB123456 ASD SMITH 1.0
AB234567 OMAR SDF 30.0
AB345678 XCV WER 69.0

我的代码是:

FILE *input = fopen("Resources\\students", "r");
if(!input){
    printf("Error while opening the file.");
    exit(-1);
}

输出是:

Error while opening the file.
Process finished with exit code 255

我也尝试过绝对路径或更改文件扩展名,但输出不会改变。我从来没有在 Linux 上遇到过这个问题。我应该怎么办?

标签: cclionwindows-subsystem-for-linux

解决方案


推荐阅读