what are the Causes of Segmentation Fault

closed account (9jAq5Di1)
i have made a simple chess program using arrays and functions which check whether a king is in check in any given configration of chess board.if a king is in check then which king is i.e white or black.

in some cases
1- it give no output but give segmentation fault at run time.
2- it give output along with segmentation fault.
3- sometime its input loop does not terminat
Can you tell me!

WHAT is segmentation fault?
What are the usuall reasons behind segmentation fault?
What may be the reasons in this case?
Is it compiler or envirment dependent?

Last edited on
http://en.wikipedia.org/wiki/Segmentation_fault

You've got either a dangling pointer or a fencepost error somewhere in your code.

Good luck.
Last edited on
To simplify. Your trying to access a memory location that is invalid. This is either by going too far into an array, or access a pointer that is no longer valid.

e.g
1
2
3
char myArray[10] = {0};
myArray[0] = 'A'; // Valid
myArray[10] = 'B'; // Error -usually SegFault, 9 Is Highest We can index 
closed account (9jAq5Di1)
Thank you very much for your instant help
Topic archived. No new replies allowed.