Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Re: memset (http://www.velocityreviews.com/forums/t441703-re-memset.html)

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:

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



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.