如何在cout尽头放置一个空间
我需要知道为什么C ++仅在COUT函数末尾看到空间。 我正在使用clion和c ++ 23(language_stantart)
int main()
{
string Item ;
double Price ;
int Quantity ;
double Total ;
cout << "Your item to buy : " ;
getline(cin, Item) ;
cout << "Price of the item : " ;
cin >> Price ;
cout << "Quantity of the item : " ;
cin >> Quantity ;
cout << endl ;
Total = Price * Quantity ;
cout << "Item : " << Item << endl ;
cout << "Price : " << Price << endl ;
cout << "Quantity : " << Quantity << endl ;
cout << "Total is : " << Total << endl ;
}
运行代码时,它会返回我,
Your item to buy :**HereIsNoSpace**
**HereIsSpace**Price of the item :
**HereIsSpace**Quantity of the item :
所以我需要在“:”而不是“:”之后输入一个
项目输入并传递到下一个字符串
I need to know why c++ doesn't see the space just at the end of cout function.
I'm using CLion and C++ 23 (language_standart)
int main()
{
string Item ;
double Price ;
int Quantity ;
double Total ;
cout << "Your item to buy : " ;
getline(cin, Item) ;
cout << "Price of the item : " ;
cin >> Price ;
cout << "Quantity of the item : " ;
cin >> Quantity ;
cout << endl ;
Total = Price * Quantity ;
cout << "Item : " << Item << endl ;
cout << "Price : " << Price << endl ;
cout << "Quantity : " << Quantity << endl ;
cout << "Total is : " << Total << endl ;
}
When I run the code, it returns me
Your item to buy :**HereIsNoSpace**
**HereIsSpace**Price of the item :
**HereIsSpace**Quantity of the item :
So I need to enter an Item just after ":" and not ": "
And as you can see probably my spaces somehow goes just after my input and passes to the next string
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然,解决方法之一是,
尝试执行以下操作:在注册表中(帮助 | 查找操作...,在其中键入注册表)禁用 run.processes.with.pty 选项并重新启动 CLion。这有帮助吗?
根据 CPP-12752 中的响应,禁用 PTY(无需重新启动 CLion,因为 CLion 重新启动后不会保存 run.processes.with.pty 选项 - CPP-8395)会有所帮助。
伙计们,我已经找到了这个问题的解决方案!
Apparently one of the workarounds is,
try doing the following: in Registry (Help | Find Action..., type Registry there) disable the run.processes.with.pty option and restart CLion. Does that help?
According to the response in CPP-12752 disabling PTY (without CLion restart, since the run.processes.with.pty option is not saved after CLion's restart - CPP-8395) helps.
Guys I've found the solve of this heck !
当您使用 CLion 时,您可以尝试禁用 PTY(帮助 | 查找操作 > 键入“注册表” > 打开注册表 > 查找并禁用 run.processes.with.pty 选项)
在此处输入图片说明
When you are using CLion, You can try disabling PTY (Help | Find Action > type "Registry" > open Registry > find and disable the run.processes.with.pty option)
enter image description here