what is segmentation fault?

Answer Posted / mohan

In C There are different types of error like

1.compile time error
2.Linker error
3.Run time error
4.Logical error

The sigmentation fault comes under Run tile error.
Let see a simple example
#include<stdio.h.
int main()
{
int i;
scanf("%d",i);
printf("%d",i);
return(0);
}

if you compile this program ,compiler can't report any
error.If you run this program in Linux Platform you got
sigmentation fault error.

This is because ,in scanf() function call instead passing
the address of the variable ,value of variable is going to
scanf() .so you got this error.

In Linux sigmentation fault is run time error reported by
memory management.

most of the time this error occurs at illegal memory access.

Is This Answer Correct ?    34 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are system calls used for process management in linux?

574


I would like to know whether Simado and Setu products are they EPBX or not ?

1922


what are different ways the context switch happens from user to kernel space or vice-versa ?

2129


Explain process management system calls in linux?

536