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的更多相关文章

  1. memset

    函数原型: void *memset(void *s, int ch, size_t n); 函数解释:将s中当前位置后面的n个字节 (typedef unsigned int size_t )用 c ...

  2. ZOJ Problem Set - 1350 The Drunk Jailer ac代码 memset

    这是一道很简单的题目,题目大概意思说下:就是有n个监狱(编号从1到n),第一次全部打开,第二次打开编号为2的倍数的,第三次打开编号为3的倍数的,以此类推...最后问你有几个监狱是打开的 题目中我使用了 ...

  3. 字符串数组初始化0 与memset 0 效率的分析

    转自:http://www.xuebuyuan.com/1722207.html 结合http://blog.sina.com.cn/s/blog_59d470310100gov8.html来看. 最 ...

  4. memset函数

    函数介绍 void *memset(void *s, int ch, size_t n); 函数解释:将s中前n个字节 (typedef unsigned int size_t )用 ch 替换并返回 ...

  5. memset函数详解

    语言中memset函数详解(2011-11-16 21:11:02)转载▼标签: 杂谈 分类: 工具相关  功 能: 将s所指向的某一块内存中的每个字节的内容全部设置为ch指定的ASCII值, 块的大 ...

  6. memset 的实现分析

    memset 是 msvcrt 中的一个函数,其作用和用途是显而易见的,通常是对一段内存进行填充,就其作用本身不具有任何歧义性.但就有人一定要纠结对数组的初始化一定要写成如下形式: int a[... ...

  7. C语言 memset函数盲点

    #include <stdio.h> #include <stdlib.h> #include <string.h> struct packet { int len ...

  8. 深入学习 memset 函数

    最近,和同学讨论了一下memset函数,趁着周五空闲做一总结. memset函数最常用的功能就是初始化数组了(主要是置零),如 #include <iostream> #include & ...

  9. 老生常谈,正确使用memset

    转自:http://blog.csdn.net/my_business/article/details/40537653 前段项目中发现一个问题,程序总是在某个dynamic_cast进行动态转换时出 ...

  10. memset中的sizeof

    记录memset中的sizeof的用法, unsigned char *buff = (unsigned char*) malloc(128 * sizeof(char)); //错误的:memset ...

随机推荐

  1. C++ Primer:第七章:类

    定义一个类: class Myclass{ int data_i; string data_str; public: int getdata_i() const { return data_i; } ...

  2. 在web.xml中配置error-page

    在web.xml中配置error-page 在web.xml中有两种配置error-page的方法,一是通过错误码来配置,而是通过异常的类型来配置,分别举例如下: 一.   通过错误码来配置error ...

  3. JS初学之-选项卡(常见)

    思路:鼠标滑过的效果直接用a:hover实现的,比较简便,缺点是在IE下不兼容.   为每一个Li添加点击事件,将每一个li用自定义属性的方法与div相匹配,重点是在点击事件内,要先遍历每一个div, ...

  4. ubuntuPC机安装JLink驱动

    摘要: 打开你仿真用的机器人的配置文化,这个应该是local_costmap_params.yaml transform tolerance g改为1     本文介绍了如何在Ubuntu平台配置J- ...

  5. ✡ leetcode 156. Binary Tree Upside Down 旋转树 --------- java

    156. Binary Tree Upside Down Add to List QuestionEditorial Solution My Submissions   Total Accepted: ...

  6. android开源项目---项目篇

    本文转载于:http://blog.csdn.net/likebamboo/article/details/19081151 主要介绍那些Android还不错的完整项目,目前包含的项目主要依据是项目有 ...

  7. numpy下的flatten()函数用法

    flatten是numpy.ndarray.flatten的一个函数,其官方文档是这样描述的: ndarray.flatten(order='C') Return a copy of the arra ...

  8. 二十四种设计模式:责任链模式(Chain of Responsibility Pattern)

    责任链模式(Chain of Responsibility Pattern) 介绍为解除请求的发送者和接收者之间耦合,而使多个对象都有机会处理这个请求.将这些对象连成一条链,并沿着这条链传递该请求,直 ...

  9. C#Linq中的Union All/Union/Intersect和Top/Bottom和Paging和SqlMethods,skip,take,takewhile,skipwhile,编译查询等

    我们继续讲解LINQ to SQL语句,这篇我们来讨论Union All/Union/Intersect操作和Top/Bottom操作和Paging操作和SqlMethods操作 . Union Al ...

  10. JavaScript中“javascript:void(0) ”是什么意思

    来源: <a href="javascript:test();void(0);">here</a> 此处:Javascript中void是一个操作符,该操作 ...