In this tutorial, we will discuss a program for understanding core dumps (segmentation faults) in C/C.
This may happen because code is trying to write on read-only memory, or trying to access a corrupted memory location.
int main(){ char *str; str = "GfG"; *(str+1) = 'n'; return 0; }
#include <iostream> using namespace std; int main(){ int arr[2]; arr[3] = 10; return 0; }
#include <stdio.h> #include<alloc.h> int main(void){ int* p = malloc(8); *p = 100; free(p); *p = 110; return 0; }
Abnormal termination of program
The above is the detailed content of Core dump (segmentation fault) in C/C++. For more information, please follow other related articles on the PHP Chinese website!