Answer Posted / vijaya aliveni.m
The physical memory in a computer is managed by the
operating system.It has different segments for different
purposes.
Here is an example of ANSI C code that should create a
segmentation fault on platforms with memory protection:
int main(void)
{
char *s = "hello world";
*s = 'H';
}
In the above ex. string "s" will hold the "hello world".
But in bellow we are trying to replace the letter "H" in the
place of "h".
But in that, pointer is only readonly we are not able to
change the charters.
So , while executing it will show the segmentation fault.
Is This Answer Correct ? | 8 Yes | 3 No |
Post New Answer View All Answers