void *memset(void *str , int c , size_t n );
Copies the character c (an unsigned char) to the first n
characters of the string str
.
The argument str is returned.
void * memset ( void * ptr, int value, size_t num );
This function has the following parameter.
size_t is an unsigned integral type.
ptr is returned.
#include <stdio.h>
#include <string.h>
int main (){
char str[] = "this is a test!";
memset (str,'-',6);
puts (str);
return 0;
}
The code above generates the following result.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//ww w . j av a2s .c om
int main(void)
{
char str[] = "this is a test";
puts(str);
memset(str,'a',5);
puts(str);
}
The code above generates the following result.