Velocity Reviews

Velocity Reviews (
-   C Programming (
-   -   Re: memset (

Vladimir S. Oka 03-09-2006 09:21 AM

Re: memset
novice wrote:
> can any body explain me the "memset()" function with example.

Yes, a good textbook, or the C Standard: The memset function

#include <string.h>
void *memset(void *s, int c, size_t n);

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.

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

All times are GMT. The time now is 10:07 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.