1.

Explain The Meaning Of "segmentation Violation"?

Answer»

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.

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.



Discussion

No Comment Found