memset用法祥解

本文改编于

http://www.cnblogs.com/PegasusWang/archive/2013/01/20/2868824.html

把里面的演示代码修改了一下,可以直接复制运行通过。环境DEV-C++

1. void *memset(void *s,int c,size_t n)
总的作用:将已开辟内存空间 s 的首 n 个字节的值设为值 c。

2. 例子:

#include<stdio.h>
#include <string.h>

int main()
{
char s[]="Happy new year of sheep!!";
memset(s,'G',5);

printf("%s",s);
return 0;
}

posted @ 2015-03-11 12:10  wkhuahuo  阅读(142)  评论(0编辑  收藏  举报