memset 用法
来源:互联网 发布:兰州seo 编辑:程序博客网 时间:2024/06/10 03:51
在你申请了一块内存之后,
比如
int *p=NULL;
p=malloc(10*sizeof(int));//申请了10个int型内存
memset(p,0,10*sizeof(int));//全部初始化为0
memset的作用就是把你快连续的内存初始化为你给的值。
Example
/* MEMSET.C: This program uses memset to
* set the first four bytes of buffer to "*".
*/
#include <memory.h>
#include <stdio.h>
void 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
- memset用法
- memset 用法
- memset用法
- memset用法
- memset用法
- memset 用法
- memset用法
- memset用法
- memset 用法
- memset 用法
- memset用法
- memset用法
- memset 用法
- memset用法
- memset用法
- memset用法
- memset用法
- memset用法
- JAVA中对文件的操作
- 共享锁与排它锁有生命不同
- VSTO在EXCEL添加VBA模块代码
- svn 分用户组、分目录权限控制
- C#做托盘程序
- memset 用法
- 使用LauchPopupListener过滤lov数据
- 在SQL Server中如何输出行号
- 如何执行.jar包中的main方法
- 英特尔推出固态硬盘加速应用程序启动
- 猫
- SQL Server CONVERT() 函数
- 近几天 用微芯力科的板子 调试usb虚拟串口的程序,发现一些问题以及解决方法。和大家共享
- 什么也不会……