reading a line from ifstream into a string variable

后端 未结 1 1540
南方客
南方客 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 <string>.

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

    So, for your case it would be:

    std::getline(read,x);
    
    0 讨论(0)
提交回复
热议问题