![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
List of Common Reasons for Segmentation Faults in C/C++
The main reason for segmentation fault is accessing memory that is either not initialized, out of bounds for your program or trying to modify string literals. These may cause a segmentation fault though it is not guaranteed that they will cause a segmentation fault. Here are some of the common reasons for segmentation faults −
- Accessing an array out of bounds
- Dereferencing NULL pointers
- Dereferencing freed memory
- Dereferencing uninitialized pointers
- Incorrect use of the "&" (address of) and "*" (dereferencing) operators
- Improper formatting specifiers in printf and scanf statements
- Stack overflow
- Writing to read-only memory
Advertisements