novice wrote:
> can any body explain me the "memset()" function with example.
Yes, a good textbook, or the C Standard:
7.21.6.1 The memset function
Synopsis
1
#include <string.h>
void *memset(void *s, int c, size_t n);
Description
2 The memset function copies the value of c (converted to an unsigned
char) into
each of the first n characters of the object pointed to by s.
Returns
3 The memset function returns the value of s.
My example (snippet):
#include <stdio.h>
#include <string.h>
int main(void)
{
char name[] = "Vladimir";
memset(name, 'X', strlen(name));
printf("%s\n", name);
return 0;
}
Should output "XXXXXXXX".
--
BR, Vladimir
|