What is the easiest way to make a C++ program crash?

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();
}

to make my C++ program crash reliably

31 Answers
31

The abort() function is probably your best bet. It’s part of the C standard library, and is defined as “causing abnormal program termination” (e.g, a fatal error or crash).

Leave a Comment