memset.c

来自「标准c库代码,可以应用于各个系统提供了大量的基本函数」· C语言 代码 · 共 75 行

C
75
字号
/*FUNCTION	<<memset>>---set an area of memoryINDEX	memsetANSI_SYNOPSIS	#include <string.h>	void *memset(const void *<[dst]>, int <[c]>, size_t <[length]>);TRAD_SYNOPSIS	#include <string.h>	void *memset(<[dst]>, <[c]>, <[length]>)	void *<[dst]>;	int <[c]>;	size_t <[length]>;DESCRIPTION	This function converts the argument <[c]> into an unsigned	char and fills the first <[length]> characters of the array	pointed to by <[dst]> to the value.RETURNS	<<memset>> returns the value of <[m]>.PORTABILITY<<memset>> is ANSI C.    <<memset>> requires no supporting OS subroutines.QUICKREF	memset ansi pure*/#include <string.h>#define STRIDE int_PTR _DEFUN (memset, (m, c, n),	_PTR m _AND	int c _AND	size_t n){  char *s = (char *) m;  int count;  STRIDE *ip;  if (c == 0)    {      /* Special case when storing zero onto an aligned boundary */      count = (((int) s) & (sizeof (STRIDE) - 1));      while (n != 0 && count > 0 && count != sizeof (STRIDE))	{	  *s++ = 0;	  count++;	  n--;	}      ip = (STRIDE *) s;      while (n >= sizeof (STRIDE))	{	  *ip++ = 0;	  n -= sizeof (STRIDE);	}      s = (char *) ip;    }  while (n-- != 0)    {      *s++ = (char) c;    }  return m;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?