By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,563 Members | 1,058 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,563 IT Pros & Developers. It's quick & easy.

What can cause Segmentation Fault on Linux?

P: n/a
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!

Nov 14 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I_have_nothing wrote:

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?

--
pete
Nov 14 '05 #2

P: n/a
Thanks!
Any OTHER major/classic reason?

Nov 14 '05 #3

P: n/a

I_have_nothing wrote:
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.

Nov 14 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.