Reading a full line of input

后端 未结 5 1835
广开言路
广开言路 2020-11-27 06:27

I\'m trying to store the input that user enters through console. so I need to include the \"enter\" and any white space.

But cin stops giving me input a

5条回答
  •  感情败类
    2020-11-27 07:23

    #include 
    #include 
    using namespace std;
    
    int main() 
        string s;
        while( getline( cin, s ) ) {
           // do something with s
        }
    }
    

提交回复
热议问题