Bus error (core dumped)
The program tried to access memory in a way that is not allowed by the hardware, often due to alignment issues.
int main() { char *ptr = "Hello"; int *iptr = (int *)(ptr + 1); // Unaligned access *iptr = 10; return 0; }
Ensure proper memory alignment and avoid accessing memory outside allocated regions.
#include <stdlib.h> int main() { int *iptr = malloc(sizeof(int)); if (iptr != NULL) { *iptr = 10; free(iptr); } return 0; }