Visual Studios - C++控制台立即打开和关闭
Visual Studios - C++ Console Opening & Closing Right Away
尝试运行这个程序,但每当它运行时,它都会迅速打开并立即关闭,不允许我与之交互。我做错了什么才能打开和关闭它?
下面是我的程序,我确定我做错了什么。
感谢您的帮助!
驱动程序.cpp
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
char Anagram();
}
字谜.cpp
#include<string>
#include<algorithm>
#include<iostream>
#include "Anagram.h"
using namespace std;
char Anagram()
{
string FirstAnagram, SecondAnagram;
char keep_going;
do
{
cout << "Enter word one: ";
cin >> FirstAnagram;
cout << "Enter word two: ";
cin >> SecondAnagram;
sort(FirstAnagram.begin(), FirstAnagram.end());
sort(SecondAnagram.begin(), SecondAnagram.end());
if (FirstAnagram == SecondAnagram)
{
cout << "They are anagrams of each other.";
}
else
{
cout << "They are not anagrams of each other.";
}
cout << "nnTry another?";
cin >> keep_going;
}
while (keep_going == 'y');
return 0;
}
字谜.h
char Anagram();
试试这个:
#include<string>
#include<algorithm>
#include<iostream>
#include "Anagram.h" // add this
using namespace std;
int main()
{
char ch = Anagram(); // call the function like this
}
尝试将其添加到main
函数的末尾:
std::cout << "Press Enter to close application.n";
std::cin.ignore(10000, 'n');
相关文章:
- 与Visual Studios(c ++)同步时如何组织github存储库?
- 尝试从 Visual Studios C++ 中的加密字符串输出解密字符串时出现逻辑错误
- 连接 MATLAB 和 Visual Studios 的问题
- C++ Visual studios 2017 CHAR_MIN将值设置为 0
- 在 Visual Studios 中关闭 rc 资源文件的编辑
- 如何在Visual Studios C++中阅读希伯来字母
- C++ Functions & Arrays - Visual Studios 中的错误 C4700
- 无法读取 .blk 文件C++ (Visual Studios)
- 由于错误,c ++代码无法在Visual Studios上运行,但不显示任何错误
- C++编译器在安装了Visual Studios和代码块的cmd中不起作用
- Visual Studios Cout <<不起作用
- 是否可以将其他文件类型添加到Visual Studios清理过程中
- Visual Studios 2012 中的默认模板参数
- Visual Studios - C++控制台立即打开和关闭
- 在Visual Studios 2010的外部依赖项文件夹中搜索文本/代码
- 将 SIMULINK 中的本机.dll文件添加到 Visual Studios C#
- 在 Visual Studios Express 2010 上设置根库
- MS Visual Studios链接错误.2010年和2013年
- Visual Studios C++代码中的错误。Lab4.obj : 错误 LNK2019: 未解析的外部符号"bool __cdecl
- Visual Studios 9 Dll链接不一致