先仔细研读其定义:
void * memset ( void * ptr, int value, size_t num );
Fill block of memory
Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char).
例子:
int a[10];
memset(a, 10, sizeof(a));
a中的10个值全为168430090。
因为10的进制为1010,每个int占4个字节(bytes,即8bits),即32bits。所以,a中的每个元素变为:
00001010 00001010 00001010 00001010
转为10进制即为168430090。