从标准输入读取包含空格的字符串 [英] reading a string containing white spaces from std input

查看:104
本文介绍了从标准输入读取包含空格的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用C ++编写代码已经很久了,我忘记了很多事情.请给我一些帮助,我可以从标准输入中读取包含空格的单个字符串,而不必为此形成循环;像名字一样(''James Berk Brown").请任何回应将不胜感激. 10x

Its been a long time i wrote my codes in C++ and i''ve forgotten many things. Pls can some1 help me with how i can read a single string containing white spaces from standard input, without having to form a loop for this; something like a name (''''James Berk Brown''''). Pls any respond would be appreciated. 10x

推荐答案

''getline''是您要寻找的功能.

http://www.cplusplus.com/reference/string/getline/ [
''getline'' is the function you are looking for.

http://www.cplusplus.com/reference/string/getline/[^]


这篇关于从标准输入读取包含空格的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆