如何存储一个完整的句子与空白的字符串在cpp
How to store a complete sentence with white spaces in a string in cpp?
我想在cpp的字符串str中存储"What is wrong with you?"但是当我运行这段代码时,它只在·str·中存储"What" .
如何在字符串中存储完整的句子。
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
string str;
cin>>str;
cout<<str;
}
输入:What is wrong with you?
输出:What
已被回复。但这是解决方案:
std::string str;
std::getline( std::cin, str);
相关文章:
- 无法通过空白将文本文件行分隔为矢量
- 如何删除peer if else分支中的冗长句子
- 由cin中的字符串中未捕获空白引起的分割错误
- 尝试从 XamlApplication 编译 C++/WinRT 空白应用程序时,我收到未解析的外部符号 winrt_make_*
- 在输入句子时终止 std::out_of_range
- 使用 C++ 验证 NMEA 句子
- 分析包含 NMEA 句子的日志文件C++
- 代码精简版页面变为空白
- 在OpenCV C++中创建空白图像
- Gtkmm 窗口为空白,不显示任何小部件或标题
- 我如何使它,无论用户用空白字符串按 Enter 多少次,它总是打印"开始"字符串?
- Vscode/C++ - cout 无法输出完整的句子,也无法与整数连接
- OpenGL - 添加第二个着色器属性会导致空白屏幕
- 如何理解句子的生命周期始于对e的评估
- 该程序将.csv文件中的一系列单词放入数组中,然后随机生成句子.但它不起作用
- 对象数组打印空白字符串
- C++从句子中删除给定字符的程序不起作用
- 如何在c++中读取do-while循环中的空白
- 如何去除句子开头的空白
- 如何存储一个完整的句子与空白的字符串在cpp