That happens when a program tries to access (read, write or execute code) memory it doesn't have the appropriate permissions for.
See virtual memory on Google or Wikipedia for more information.
You can find the cause by running the debug build of your program in a debugger.
When a segmentation fault occurs, the debugger can show you the line that caused it, the function callstack and it allows you to inspect the values of relevant variables.
An error produced by the program and detected by the OS that occurs when the program attempts any of the following:
* Reading from memory it's not allowed to read from.
* Writing to memory it's not allowed to write to.
* Freeing a pointer twice.
Note that a segmentation fault can be triggered any amount of time after the error that caused it occurred; even never. This is why you can't guarantee that a program has no memory errors simply because it doesn't crash.
repeatable segfaults are usually not too difficult to debug (debuggers will usually give you a good clue)
You're so right. I freaking love segFaults; the debugger identifies the exact line that tries to fiddle with memory it's not supposed to, and (usually) bish-bash-bosh all-fixed in minutes.