尝试运行程序时会收到调试错误
receiving a debug error when attempting to run program
我在尝试运行程序的第一部分时会收到以下调试错误:
调试错误!
程序: ... user desktop punchline Program debug punchlineProgram.exe 模块: ... User Desktop Punchline Program Debug PunchlineProgram.exe
文件: 运行时检查失败#3 -T (按重试调试应用程序)
我试图让用户选择他们是否想听听开玩笑,运行,以及是否会根据其响应向用户输出消息的其他语句。如果我评论这些语句,则在尝试运行程序时不会收到错误。我知道我可能缺少一些简单的东西,因为我是新手。这是我到目前为止的代码:
/*Include Section*/
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <cctype>
/*Namespace Section*/
using namespace std;
/*Function Prototypes Section*/
void displayAllLines(ifstream &infile);
void displayLastLine(ifstream &infile);
/*Main section: this is the entry point of the program, which controls the flow of execution*/
int main()
{
string file1;
string file2;
ifstream joke;
ifstream punchline;
int decision;
char y;
char n;
cout << "*******************************************************************************" << endl;
cout << setw(48) << "Punchline Program" << endl;
cout << "*******************************************************************************" << endl;
cout << endl;
cout << "Welcome to the Punchline Program!" << endl;
cout << "Are you ready to hear a joke? (y or n): ";
cin >> decision;
if (decision == y)
{
cout << "Great! Let's get started!" << endl;
}
else if (decision == n)
{
cout << "Ah, no sense of humor, I see. Time to make like a tree and leaf (queue rimshot)!" << endl;
}
system("PAUSE");
}
任何帮助将不胜感激!
与char进行比较时,您应该使用':char答案
if (answer == 'y') { *//this only checks for LOWER case y*
cout << "You selected Yes" << endl;
}
与字符串相比时使用"int/float/double ...您只能使用变量。
除此之外,您的 dekist in in n n hs n he n he n he n he n he n he n char n he n hs in hs in char,并且您不需要char y nor n n 。(您自己甚至从未在该代码中使用过)
我建议查看C 教程,大多数显示和解释char/string之间的不同之处,"answers"。
相关文章:
- C++为什么我的编译器成功了,但我的计算机给出了调试错误?
- 分段错误 .AnsiStringToUnicodeString 作为第一个调试错误行.杜比奥斯类等级制度
- 尝试在我的基类中启动线程时,Visual Studio 由于调试错误而中止我的程序
- OpenGL 调试 错误回调函数的 ID 参数是什么?
- 如何调试错误代码 77:cudaErrorIllegal地址当 cuda-memcheck 没有发现问题时
- 如何调试错误消息"abort() has been called"?
- Eclipse调试错误:没有此类文件或目录 n
- 调试错误,在C++中检测到堆损坏
- Qt:如何在QByteArray中调试错误的分配异常
- 尝试运行程序时会收到调试错误
- C 高分列表调试错误
- 我的C++函数不断收到调试错误。我不确定我做错了什么
- 使用 GDB 在 main() 之前调试错误
- c++中的调试错误
- 多线程效率低下:调试错误共享
- 调试错误.已调用R6010中止()
- C++的调试错误真的很令人沮丧
- SDL 项目的调试错误"没有可用于 main() 的源代码"
- 调试错误R6010-已调用abort()
- 程序在Visual Studio Community 2015中执行后,它会显示调试错误