MSDN举的memset函数的例子:
#include <memory.h>
#include <stdio.h>
int main( void )
{
char buffer[] = "This is a test of the memset function";
printf( "Before: %s/n", buffer );
memset( buffer, '*', 4 );
printf( "After: %s/n", buffer );
}
Output//输出结果如下
Before: This is a test of the memset function
After: **** is a test of the memset function
函数原型:
void *memset( void * dest , int c , size_t count );
memsetMSDN的解释及翻译:
Sets the first count chars of dest to the character c 把dest最开头的几个字符更换为count个c对应的字符
Security Note Make sure that the destination buffer is the same size or larger than the source buffer.//确定目标字符串的长度和源字符串更长或相同