c++ - 我想换档进入 C++ 但它立即关闭
问题描述
我是 C++ 新手,我遵循 cin 指南,他使用 getline() 函数让程序等到客户端按 Enter 键关闭程序,这对他有用,但在我输入第一个输入后我的程序仍然立即关闭(我不希望用户必须输入一些东西,所以请不要标记为重复!)
#include <iostream>
#include <filesystem>
#include <string>
using namespace std;
int main()
{
string santype;
cout << "What type of sandwhich you want kid?" << endl;
cin >> santype;
cout << "Creating " << santype << " Sandwhich" << endl;
cout << "Press Enter To Exit..";
getline(cin, santype);
}
解决方案
推荐阅读
- node.js - 了解 Lambda 以调用 API
- c# - 检索启动进程的实际用户帐户
- c++ - 如何在if语句c ++中将字符串转换为更低
- javascript - 类值上的 MutationObserver
- node.js - 节点:模块解析失败:意外令牌“您可能需要适当的加载程序来处理此文件类型”
- python - 选择一定范围的行创建一个db
- zapier - IFTTT - 从 URL 下载文件列表
- r - 用泊松 glm 绘制两条曲线,并在分类变量中进行交互
- javascript - 使用原型使用 JavaScript 计算圆柱体的体积
- debugging - 有没有办法通过 WiFi 部署/调试 Cordova Android Ionic 应用程序?