JIN_GAG 2021-05-23 14:11 采纳率: 50%
浏览 42
已采纳

编译成功但读取不了文件?

我编译通过了,但程序什么都不显示,求大佬帮助,record.txt和本程序在同一个文件夹且有内容。
#include <iostream>
#include <fstream>
#include <cstring>
int main()
{
    using namespace std;
    ifstream fin("record.txt");
    string Rname;
    fin >> Rname;
    cout << Rname;
    fin.close();
    system("pause");
    return 0;
}
  • 写回答

3条回答 默认 最新

  • CSDN专家-cpp_learner 2021-05-23 14:13
    关注

    你还没打开文件呢!open

    ifstream inFile;

    inFile.open("demo.txt"); // 默认当方式打开文件

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?