What can cause Segmentation Fault on Linux?

I

I_have_nothing

Hi!
I am new in C. I got a lots of "Segmentation Fault"s in my code.
I guess One possibility is:
if " int array_i[10]; " is declard and the code trys to access
"array_i[10]",
a Segmentation Fault will be returned by gcc compiler on linux.

What are the other "major" reasons to have "Segmentation Fault"?
I hope this is not a stupid question and someone is will to give me
some exampls(part of code) with errors a newer might esasily make and
then gets "Segmentation Fault".
Thank you so much!
 
P

pete

I_have_nothing said:
Hi!
I am new in C. I got a lots of "Segmentation Fault"s in my code.
I guess One possibility is:
if " int array_i[10]; " is declard and the code trys to access
"array_i[10]",
a Segmentation Fault will be returned by gcc compiler on linux.

What are the other "major" reasons to have "Segmentation Fault"?

That's the classic reason:
Attempting to access memory that the program doesn't own.

You are aware that array_i[10] is undefined in your program, right?
 
J

Jason

I_have_nothing said:
Thanks!
Any OTHER major/classic reason?

SEGV is usually caused by some form of illegal memory access. Trying to
list all the possible causes of this error, however, would be like
trying to list all the reasons why your car could break down while
driving.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top