如何调试错误消息"abort() has been called"?
How to debug the error message "abort() has been called"?
代码下没有红线。当我开始不调试时,输入电子邮件后,弹出了故障," Abort()被称为"。我该如何调试?
#include <iostream>
#include <string>
using namespace std;
int main() {
string email;
bool good = false;
while (good == false)
{
there:
cout << "Email is ";
cin.ignore();
getline(cin, email);
cout << email.length();
int a;
for (int q = 0; q <= email.length(); q++)
{
char x = email.at(q);
int count = 0;
while (x == '@')
{
a = 1;
count++;
}
if (count > 1)
{
a = 0;
}
}
if ((email.at(0) == '@') || (email.at(email.length()) == '@') || (a == 0))
{
cout << "Input is invalid. One character ‘@’ must be found. Moreover, there must be some characters before and after the character ‘@’." << endl;
goto there;
}
else
{
good = true;
}
}
}
我在您的代码中看到了很多问题。首先检查我的评论,以了解您的循环。
接下来,在您的循环中,如果第一个字符确实是"@",则您将是无限的循环,因为您永远不会脱离它。
while (x == '@')
{
a = 1;
count++;
}
相关文章:
- std::unordered_map 类型对象声明期间出现"field has incomplete type"错误
- 使用"std::enable_if_t" "function template has already been defined"
- 在macOS Mojave上尝试OpenCV视频捕获时"Abort Trap: 6"
- 使用 GraphicsPath::AddString() 抱怨"class 'GraphicsPath' has no member 'AddString'"
- C++中链表的错误"Abort signal from abort(3) (sigabrt) "
- 'Project.exe has triggered a breakpoint.'
- C++ 结构数组 - "This declaration has no storage class or type specifier"
- Rcpp 'candidate function has different number of parameters (expected 0 but has 1)'
- 在 EAX 模式下加密数据时"program has stopped working"
- "xvalue has identity"是什么意思?
- 实现多线程后"Project.exe has triggered a breakpoint"
- 为什么删除执行组件指针会导致"Program.exe has triggered a breakpoint"
- C++ abort() 在函数内的抽象类对象指针调用上
- "Field has incomplete type"引用自己的类的问题
- 如何在过载时强制"statement has no effect"警告==
- C++ 中的"this declaration has no storage class or type specifier"错误
- 如何在链接器设置和搜索目录更改后修复" '::iswblank' has not been declared"
- MacPorts:"Error: clang-4.0 has been replaced by clang-8.0; please install that instead",但我已经安装了clang
- 程序在VS2017上以"abort() has been called"错误结束
- 如何调试错误消息"abort() has been called"?