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

jonathan topf picture jonathan topf · Dec 12, 2011 · Viewed 75k times · Source

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

Answer

duskwuff -inactive- picture duskwuff -inactive- · Dec 12, 2011

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).