C++ How to avoid the enter key when using cin and getline
2013-09-11 04:43
555 查看
cout<<"Enter your last name: ";
cin.ignore(); //忽略流中的一个字符,这里忽略的是一个回车,没加这个时,name2接受的其它是回车
getline(cin,name2);
cin.ignore(); //忽略流中的一个字符,这里忽略的是一个回车,没加这个时,name2接受的其它是回车
getline(cin,name2);
相关文章推荐
- How can selenium web driver get to know when the new window has opened and then resume its execution
- How to get the file's icon using C++ - 用C++如何获取文件的图标
- How to get a type in C++ when its template argument is the argument
- CodeSnip: How to Get Id of the Record Using ASP.NET and SQL Server 2000
- How to get the password text in a text with password property from another process using C++ - 用C++如何从不同进程获取密码框文本
- Linux - How to remove the new line at the end of file when using vim
- How to Simulate the Price Order or Price Line Function using API QP_PREQ_PUB.PRICE_REQUEST Includes
- How to authenticate against the Active Directory by using Forms authentication and Visual C# .NET
- how to get geometry type of layer using IMapServer3 and IMapLayerInfo? (C#)
- How to output the message when using the function 'printf'
- How to get the value of a form element : check box and radio button
- How to get the data from a cell when I click on the GridButtonColumn of the same row
- Photoshop CS2 RAW : Using Adobe Camera Raw, Bridge, and Photoshop to Get the Most out of Your Digita
- JSP URI/URL - How to get the request URI, URL, and Context from a JSP
- SQL - How to get the current day, month and year
- how to get geometry type of layer using IMapServer3 and IMapLayerInfo? (C#)
- How to Release the Temp LOB Space and Avoid Hitting ORA-1652 (文档 ID 802897.1)
- How to query_posts using meta_query to orderby meta_key AND have a secondary sort by date?
- A c++ class wrapper to simplify the use of CRITICAL_SECTION and avoid dead-lock
- How to resolve mysql problem when you get code 2003(10061) and 1130