memset函数
来源:互联网 发布:武汉破获网络贩枪 编辑:程序博客网 时间:2024/05/22 00:14
函数原型:extern void *memset(void *buffer, int c, int count)
参数说明:buffer为源字符串,c为要初始化的字符的值,count为初始化buffer中字符的个数。
所在库名:#include <string.h>
函数功能:把buffer所指内存区域的前count个字节设置成字符c。
返回说明:返回void*类型指针。
其它说明:通常可以用它来初始化数组的信息,这样使用很方便。
实例:
#include<string.h>
#include<stdio.h>
int main()
{
char str[100]="Hello,I am sky2098,I liking programing!";
char character='H' ; //指定一个字符
void *voidtemp;
printf("Before Setting the str is: %s ! ",str);
voidtemp=memset(str,character,strlen("Hello,I am sky2098"));
if(voidtemp!=NULL)
{
printf("Set Success! ");
printf("After Setting the str is: %s ! ",str);
}
else
{
printf("Set Failure! ");
printf("After Setting the str is: %s ! ",str);
}
return 0;
}
#include<stdio.h>
int main()
{
char str[100]="Hello,I am sky2098,I liking programing!";
char character='H' ; //指定一个字符
void *voidtemp;
printf("Before Setting the str is: %s ! ",str);
voidtemp=memset(str,character,strlen("Hello,I am sky2098"));
if(voidtemp!=NULL)
{
printf("Set Success! ");
printf("After Setting the str is: %s ! ",str);
}
else
{
printf("Set Failure! ");
printf("After Setting the str is: %s ! ",str);
}
return 0;
}
在VC++ 6.0 编译运行:
- memset函数
- memset函数
- memset()函数
- memset函数
- memset 函数
- memset函数
- memset() 函数
- memset函数
- memset函数
- memset函数
- memset 函数
- memset函数
- memset 函数
- memset函数
- memset函数
- memset 函数
- memset函数
- memset函数
- 基于自然云的云计算模型
- mysql_stmt_prepare
- Minicom
- java设计模式(一)之单例模式详解
- 获取盘符,并对盘符进行循环类型监测
- memset函数
- iOS学习之UINavigationController详解与使用(一)添加UIBarButtonItem
- Rob Pike:走进Go语言
- OSG 碰撞检测
- DBA素质之-个性
- C#中进度条的写法
- 由浅入深探究mysql索引结构原理、性能分析与优化
- android分享到新浪微博,腾讯等各大网站
- memchr函数