memset, wmemset
Imposta i buffer a un carattere specificato.
void *memset(
void *dest,
int c,
size_t count
);
wchar_t *wmemset(
wchar_t *dest,
wchar_t c,
size_t count
);
Parametri
dest
Puntatore alla destinazione.c
Un carattere da impostare.count
Numero di caratteri
Valore restituito
Valore di dest.
Note
Imposta i primi count caratteri di dest con il carattere c.
Nota di sicurezza Assicurarsi che il buffer di destinazione disponga di spazio sufficiente per almeno count caratteri. Per ulteriori informazioni, vedere Evitare sovraccarichi del buffer.
Requisiti
Routine |
Intestazione obbligatoria |
---|---|
memset |
<memory.h> o <string.h> |
wmemset |
<wchar.h> |
Per ulteriori informazioni sulla compatibilità, vedere Compatibilità nell'Introduzione.
Librerie
Tutte le versioni delle Librerie di runtime C.
Esempio
// 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 );
}
Output
Before: This is a test of the memset function
After: **** is a test of the memset function
Di seguito è riportato un esempio di utilizzo di 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 );
}
Output
Before: This is a test of the wmemset function
After: **** is a test of the wmemset function
Equivalente .NET Framework
Vedere anche
Riferimenti
_strnset, _strnset_l, _wcsnset, _wcsnset_l, _mbsnset, _mbsnset_l