How do you open a file in C++?

后端 未结 9 870
-上瘾入骨i
-上瘾入骨i 2021-02-01 15:41

I want to open a file for reading, the C++ way. I need to be able to do it for:

  • text files, which would involve some sort of read line function.

9条回答
  •  清歌不尽
    2021-02-01 16:05

    #include 
    
    ifstream infile;
    infile.open(**file path**);
    while(!infile.eof())
    {
       getline(infile,data);
    }
    infile.close();
    

提交回复
热议问题