why do segmentation fault happen code example

Example 1: segmentation fault means

## Segmentation Fault ##

when it will come ? READ Conditions below ...

- segmentation fault comes when you have an array of 10 size and
  you are accessing the arr[12] so you are accessing the unknown memory
  which is not yours so it will gives you error...
  
- If you are asking for memory but it doesnt have any memory left so error...

...so both conditions above will gives you error as segmentation fault.

Example 2: segmentation fault

Segfaults are caused by a program trying to read or write an illegal memory location

Tags:

Misc Example