Detecting ENTER key in C++

前端 未结 7 723
不知归路
不知归路 2020-12-17 03:07

I have a program like this,

char name[100];
char age[12];
cout << \"Enter Name: \";
cin >> name;

cout << \"Enter Age: \";
cin >> age         


        
相关标签:
7条回答
  • 2020-12-17 03:40

    When you use cin.get() compiler will take the lastly used Enter(i.e Enter key pressed while entering name). so you need to make the compiler to avoid the lastly entered Enter key to do so you need to include cin.ignore() before using cin.get().

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