Clobbering

In computer science, under Override (English clobbering ) is understood to overwrite a file or memory overwrite, which is usually unintentional. We rarely used the word rewriter when a source point inadvertently corrupts memory.

Overwriting often happens accidentally, such as by calling the output redirection operator (>). To avoid this, various means used, such as to set the shell parameter set-o noclobber eg (bash, ksh) or set noclobber (csh, tcsh ). This prevents > overrides by an error message appears:

$ Echo "Hello, world" > file.txt $ Echo "This will overwrite the first greeting. " > file.txt $ Set -o noclobber $ Echo " Can we overwrite it again? " > file.txt - bash: file.txt: can not overwrite existing file $ Echo " But we can use the> | operator ignore the noclobber. " > | file.txt $ # Successfully overwrote the contents of file.txt using the> | operator $ Set o noclobber # Changes setting back In high-level languages ​​such as C, shall not be mentioned due to the concept usually applied to the overwriting a memory location. To avoid overwriting a memory location, keywords, the compiler can usually be found. In the C programming language, the keyword const is provided for this project, but it should not be confused with the preprocessor directive # define. If the compiler in semantic analysis determined that a variable should be overwritten despite agreement, an error is usually delivered and canceled the translation process.

In the following example code, the variable a with the keyword const is declared as a constant. In a subsequent attempt at translation with the gcc compiler, an error message is issued.

Int main ( void) {      const int a = 3;      a = 4;      return 0; } test.c: In function ' main': test.c: 7:2: error: assignment of read-only variable 'a' References

789219
de