码迷,mamicode.com
首页 > 其他好文 > 详细

memset()

时间:2018-01-03 22:42:07      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:library   一个   ima   function   img   系统   memset   技术分享   ide   

以前没有用过这个函数,在一个示例中看到,查了一下。

关于函数“memset()”,参考:https://msdn.microsoft.com/en-us/library/aa246471(VS.60).aspx

 

函数原型:void *memset( void *dest, int c, size_t count );

作用:将缓冲区的内容设为指定的字符。

参数:dest - 指向目标地址的指针;

   c - 用来覆盖缓冲区的内容的字符;

   count - 指定需要覆盖的长度。

 


 

IDE: Code::Blocks

操作系统:Windows 7 x64

 1 /* This program uses memset to
 2  * set the first four bytes of buffer to "*".
 3  */
 4 
 5 #include <memory.h>
 6 #include <stdio.h>
 7 
 8 int main( void )
 9 {
10    char buffer[] = "This is a test of the memset function";
11 
12    printf( "Before: %s \n", buffer );
13    memset( buffer, *, 4 );
14    printf( "After:  %s \n", buffer );
15 
16    return 0;
17 }

 

运行结果:

技术分享图片

 

memset()

标签:library   一个   ima   function   img   系统   memset   技术分享   ide   

原文地址:https://www.cnblogs.com/Satu/p/8185766.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!