简体   繁体   English

进行字符串输入

[英]Taking string input

How to take string input in C++? 如何在C ++中获取字符串输入?

I generally use gets. 我通常使用获取。 But is doesn't work for 2-D arrays. 但是不适用于二维数组。 On the other hand cin ignores the text after a blank. 另一方面,cin忽略空格后的文本。 I want the input to be the exact unformatted text. 我希望输入是确切的无格式文本。

You can use it like this:- 您可以像这样使用它:

char input[100];
cin.getline(input,100);

Check out the cin.getline() 查看cin.getline()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM