C++中的文件读写操作

img


我把代码已经去敲出来了,但是输出的时候显示不出文件里的信息,但是代码没报错。请问一下要怎么写这个问题的代码呀。非常感谢回答。


#include<iostream>
#include<fstream>
#include<string>
#include<vector>
using namespace std;
int main(int argc, char**argv)
{
        fstream myfile;
        myfile.open("./a.csv", ifstream::in);
        if (myfile.is_open())
        {
                vector<string> vStr;
                string buff;
                while (getline(myfile, buff))
                {
                        vStr.push_back(buff);
                }

                for(auto i : vStr)
                {
                        cout << i<< endl;
                }
        }
        myfile.close();

        return 0;
}