Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: memset

Reply
Thread Tools

Re: memset

 
 
Vladimir S. Oka
Guest
Posts: n/a
 
      03-09-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: "memset" vs "= {0}"...Are they equivalent if your initializing variables? C++ 1 09-23-2004 02:03 PM
Re: "memset" vs "= {0}"...Are they equivalent if your initializing variables? C++ 0 09-23-2004 01:28 PM
"memset" vs "= {0}"...Are they equivalent if your initializing variables? Nollie@runtime.com C++ 17 09-22-2004 06:06 PM
memset vs fill and iterators vs pointers Joe C C++ 5 08-24-2004 11:51 AM
2 questions: speed of memset() and pointer to multi-arrays k-man C++ 4 12-18-2003 08:52 PM



Advertisments