reading a line from ifstream into a string variable

后端 未结 1 1554
南方客
南方客 2020-11-27 18:14

In the following code :

#include 
#include 
#include 

using namespace std;

int main() {
    string x = \"This          


        
1条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 18:44

    Use the std::getline() from .

     istream & getline(istream & is,std::string& str)
    

    So, for your case it would be:

    std::getline(read,x);
    

    0 讨论(0)
提交回复
热议问题