首页 > 解决方案 > 在 Visual Studio 2019 C++ 中读取 txt 文件

问题描述

我正在尝试为此程序打开一个文件。我曾尝试使用 C:\User... 之类的示例直接对其进行路径处理,但由于某种原因,它仍然说找不到该文件。我已经在 Internet 和 youtube 上查看了使用 C++ 打开文件的方法,而且非常简单。但是我仍然无法读取这个 .txt 文件。也许它与Visual Studio有关?

FILE* in_fp, * fopen();


int main() {
    if  ((in_fp = fopen("TextFile.txt", "r")) == NULL)
        printf("ERROR - cannot open front.in \n");
    else
{
    getChar();
    do {
        lex();
    } while (nextToken != EOF);
}

}

标签: c++

解决方案


推荐阅读