本文主要是介绍C++ How to avoid the enter key when using cin and getline,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
cout<<"Enter your last name: ";
cin.ignore(); //忽略流中的一个字符,这里忽略的是一个回车,没加这个时,name2接受的其它是回车
getline(cin,name2);
这篇关于C++ How to avoid the enter key when using cin and getline的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!