Segmentation violation

Explain the meaning of "Segmentation violation".

A segmentation violation usually indicates an attempt to access memory which doesn't even exist.

Segmentation violation usually occurs at the time of a program’s attempt for accessing memory location, which is not allowed to access. The following code should create segmentation violation.
main() {
char *hello = “Hello World”;
*hello = ‘h’;
}

At the time of compiling the program, the string “hello world” is placed in the binary mark of the program which is read-only marked. When loading, the compiler places the string along with other constants in the read-only segment of the memory. While executing a variable *hello is set to point the character ‘h’ , is attempted to write the character ‘h’ into the memory, which cause the segmentation violation. And, compiler does not check for assigning read only locations at compile time.
What is "Bus error"?
A bus error indicates an attempt to access memory in an illegal way,perhaps due to an unaligned pointer....
Recursion in C
A programming technique in which a function may call itself....
What does static variable mean in C?
Static is an access qualifier that limits the scope but causes the variable to exist for the lifetime of the program....
Post your comment