This single statement is the quickest, most elegant, most portable way i have seen yet to produce a crash. It is a bit of C++ code that, when executed, attempts to begin at memory address zero and, starting there, rewrite the entire contents of memory with zeroes. The nature of the resulting crash varies from OS to OS.

Linux and other UNIX-like systems, with their full, complete memory protection, will simply emit Segmentation fault (core dumped) and continue working as they did before. To see this quickly demonstrated on a linux box, try entering the following at the command line (assuming you're using Bash):
echo "void main(){for(int *p=0;;*(p++)=0);}">crash.cpp;g++ crash.cpp -o crash;./crash;

On the Mac OS, where there is no protected memory whatsoever, the loop will result in the entire system locking up completely. You won't even be able to move the mouse. On most of the newer macs, you won't even be able to reset by normal methods, and may have to actually unplug the computer if it's one of the early iMacs. If you're lucky enough to have an emergency reset button on the case, it will work. (Mac OS X, meanwhile, will simply kill the process and give an unexpected quit message, since it is technically BSD UNIX.)

On Windows NT and Windows 9x, you will get an error along the lines of "This program has performed an illegal operation and will be shut down". Note, however, that this does not mean has real memory protection. It doesn't. Windows NT (AKA "Windows 2000" or "Windows XP") does, but any OS based on the 9x kernel (including 95, 98 and Windows Millennium) does not. For details on this, as well as a variation on the code which will lock up Win9x completely, see my node Windows 9x does not have true memory protection.
I haven't tried the Loop yet in MS-DOS but i'd imagine the results are pretty nasty.

Note that the for loop given is C++ code and will not work in C. C will not allow variable initialization in the initialization of a for loop. For a c-friendly version, try:
void main(){int *p=0;for(;;)*(p++)=0;}

Log in or registerto write something here or to contact authors.