segmentation fault core dumped c++ code example
Example 1: segmentation fault means
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 (core dumped) ubuntu
See AU: What is a segmentation fault? post and also this post which have some examples how reproduce it, SO: What is segmentation fault?.
The simplest description I can come with (may be not the perfect):
Example 3: Segmentation fault (core dumped)
Core Dump/Segmentation fault is a specific kind of error caused by
accessing memory that “does not belong to you.”
In C++ this can be caused by:
~Accessing an address that is freed
~Accessing out of array index bounds
~Stack Overflow
~Dereferencing uninitialized pointer