01: // assert() macro
02: #include <stdio.h>
03: #include <stdlib.h>
04: #include <assert.h>
05: 
06: int main(int argc, char **argv) {
07:   int x = 7;
08: 
09:   /*  assume that here there is a lot of code, and
10:       that, by mistake, the content of x is changed!
11:       this is a bug if I assume that x is 7.
12:       an assert can easily spot this situation
13:    */
14:   x = 9; // my bug
15: 
16:   // assertion that check the code
17:   assert(x==7);
18: 
19:   /* Rest of the code */
20: 
21:   return 0;
22: }
23: 


Se avete commenti o osservazioni su questa pagina
mandate un messaggio di posta elettronica a bertoƶƶi@ce.unipr.it