0032-memset.c (332B)
1 #include <assert.h> 2 #include <stdio.h> 3 #include <string.h> 4 5 /* 6 output: 7 testing 8 done 9 end: 10 */ 11 12 int 13 main() 14 { 15 char *p, buf[40]; 16 17 puts("testing"); 18 19 memset(buf, 2, sizeof(buf)); 20 for (p = buf; p < &buf[40]; ++p) 21 assert(*p == 2); 22 23 memset(buf, 0, 0); 24 for (p = buf; p < &buf[40]; ++p) 25 assert(*p == 2); 26 27 puts("done"); 28 29 return 0; 30 }