Issue with cin when spaces are inputted, using string class

后端 未结 3 1459
时光取名叫无心
时光取名叫无心 2020-12-03 08:56

I have the following code:

main.cpp

#include 
#include 

using namespace std;

string name;
string age;

int main() {
          


        
3条回答
  •  感动是毒
    2020-12-03 09:25

    In C++ programming language use getline(cin, name); for string variable input.

    Where cin can be any istream and name is a string that you want to hold the value.

提交回复
热议问题