Udostępnij za pośrednictwem


memset, wmemset

Ustawia określony znak buforów.

void *memset(
   void *dest,
   int c,
   size_t count 
);
wchar_t *wmemset(
   wchar_t *dest,
   wchar_t c,
   size_t count
);

Parametry

  • docelowy
    Wskaźnik myszy do miejsca przeznaczenia.

  • c
    Znak, aby ustawić.

  • Licznik
    Liczba znaków.

Wartość zwracana

Wartość dest.

Uwagi

Określa pierwszy count znaków z dest do znaku c.

Uwaga zabezpieczeń upewnić się, że bufor docelowy co najmniej ma za mało miejsca dla count znaków.Aby uzyskać więcej informacji, zobacz Overruns buforu unikanie.

Wymagania

Rozpoczęto wykonywanie procedury

Wymaganego nagłówka

memset

<memory.h> lub <string.h>

wmemset

<wchar.h>

Aby uzyskać dodatkowe informacje o zgodności, zobacz zgodności we wprowadzeniu.

Biblioteki

Wszystkie wersje biblioteki uruchomieniowej c.

Przykład

// crt_memset.c
/* This program uses memset to
 * set the first four chars of buffer to "*".
 */

#include <memory.h>
#include <stdio.h>

int main( void )
{
   char buffer[] = "This is a test of the memset function";

   printf( "Before: %s\n", buffer );
   memset( buffer, '*', 4 );
   printf( "After:  %s\n", buffer );
}

Dane wyjściowe

Before: This is a test of the memset function
After:  **** is a test of the memset function

Poniżej przedstawiono przykład wykorzystania wmemset:

// crt_wmemset.c
/* This program uses memset to
 * set the first four chars of buffer to "*".
 */

#include <wchar.h>
#include <stdio.h>

int main( void )
{
   wchar_t buffer[] = L"This is a test of the wmemset function";

   wprintf( L"Before: %s\n", buffer );
   wmemset( buffer, '*', 4 );
   wprintf( L"After:  %s\n", buffer );
}

Dane wyjściowe

Before: This is a test of the wmemset function
After:  **** is a test of the wmemset function

Odpowiednik w programie .NET Framework

System::Buffer::SetByte

Zobacz też

Informacje

Manipulowanie buforu

_memccpy

memchr, wmemchr

memcmp, wmemcmp

memcpy, wmemcpy

_strnset, _strnset_l, _wcsnset, _wcsnset_l, _mbsnset, _mbsnset_l