码迷,mamicode.com
首页 > 编程语言 > 详细

(C/C++) memset

时间:2014-10-16 13:09:42      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:http   os   ar   for   strong   sp   on   ef   bs   

C语言:

memset
   extern void *memset(void *buffer,int c,int count);
   #include <string.h>
   功能:把buffer所指内存区域的前count个字节设置成字符c
   说明:返回指向buffer的指针.

 

char a[100];
          memset(a,‘\0‘,sizeof(a));

 

C#:

byte[]   test =   new   byte[65536];    

Array.Clear(test,0,test.Length);  

 

You could use Enumerable.Repeat:

byte[] a = Enumerable.Repeat((byte)10, 100).ToArray();

The first parameter is the element you want repeated, and the second parameter is the number of times to repeat it.

This is OK for small arrays but you should use the looping method if you are dealing with very large arrays and performance is a concern.

(C/C++) memset

标签:http   os   ar   for   strong   sp   on   ef   bs   

原文地址:http://www.cnblogs.com/fdyang/p/4028314.html

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