What is the easiest way to make a C++ program crash?(使 C++ 程序崩溃的最简单方法是什么?)
问题描述
我正在尝试制作一个 Python 程序来与不同的崩溃进程交互(这不在我的掌控之中).不幸的是,我正在与之交互的程序甚至不会可靠地崩溃!所以我想制作一个故意崩溃的快速 C++ 程序,但我实际上并不知道最好和最短的方法,有谁知道在我的之间放什么:
I'm trying to make a Python program that interfaces with a different crashy process (that's out of my hands). Unfortunately the program I'm interfacing with doesn't even crash reliably! So I want to make a quick C++ program that crashes on purpose but I don't actually know the best and shortest way to do that, does anyone know what to put between my:
int main() {
crashyCodeGoesHere();
}
让我的 C++ 程序可靠地崩溃
to make my C++ program crash reliably
推荐答案
试试:
raise(SIGSEGV); // simulates a standard crash when access invalid memory
// ie anything that can go wrong with pointers.
发现于:
#include <signal.h>
这篇关于使 C++ 程序崩溃的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使 C++ 程序崩溃的最简单方法是什么?
基础教程推荐
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- c++ STL设置差异 2022-01-01
