Life is Good.

Enhance Tech and English
随笔 - 65, 文章 - 20, 评论 - 21, 引用 - 0
数据加载中……

12 - memset

/***
*char *memset(dst, val, count) - sets "count" bytes at "dst" to "val"
*
*Purpose:
*       Sets the first "count" bytes of the memory starting
*       at "dst" to the character value "val".
*
*Entry:
*       void *dst - pointer to memory to fill with val
*       int val   - value to put in dst bytes
*       size_t count - number of bytes of dst to fill
*
*Exit:
*       returns dst, with filled bytes
*
*Exceptions:
*
******************************************************************************
*/

void * __cdecl memset (
  
void *dst,
  
int val,
  size_t count
  )
{
  
void *start = dst;

  
while (count--) {
    
*(char *)dst = (char)val;
    dst 
= (char *)dst + 1;

  
return(start);
}

posted on 2011-06-11 21:32 Mike Song 阅读(168) 评论(0)  编辑 收藏 引用 所属分类: C字符串函数源码分析


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理