cin.getline在输入char时:
using namespace std;
const int ArSize = ;
char name[ArSize];
char dessert[ArSize]; cout << "Enter your name:\n";
cin.getline(name, ArSize); // reads through newline
cout << "Enter your favorite dessert:\n";
cin.getline(dessert, ArSize);
getline在输入string时:
#include<iostream>
#include<string>
using namespace std; int main()
{
string name;
string dessert; cout<<"Enter your name:\n";
getline(cin,name);
cout<<"Enter your favorite dessert:\n";
getline(cin,dessert);