Why do we get segmentation fault error?
Segmentation fault occurs when your program tries to access an invalid location or when it tries to write to a read-only location. This error occurs only at the run-time of a program in *nix∞
Accessing an array out of its bounds.
Dereferencing an uninitialized pointer.
Trying to modify a read-only location(like string literals).
Wikipedia article on Segmentation fault∞