memset

void * memset ( void * ptr, int value, size_t num );

Fill block of memory

Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char).

#include <stdio.h>
#include <string.h>

int main ()
{
  char str[] = "almost every programmer should know memset!";
  memset (str,'-',8);
  puts (str);
  return 0;
}

posted @ 2011-10-19 14:45  greencolor  阅读(252)  评论(0编辑  收藏  举报