what the function do?

1 view
Skip to first unread message

Neha

unread,
Mar 1, 2011, 11:03:26 AM3/1/11
to Knowledge Test
what does the memset() function do?

akanksha shukla

unread,
Mar 1, 2011, 12:33:19 PM3/1/11
to knowledge-...@googlegroups.com
To set all the bytes in a block of memory to a particular value, use memset().

void *memset( void *s , int c, size_t  n);

The memset() function copies c (converted to an unsigned char) into each of the first n bytes of the object pointed to by s.

Ravina soni

unread,
Mar 1, 2011, 12:37:12 PM3/1/11
to knowledge-...@googlegroups.com


Its not exactly clear ...what is memset ?

akanksha shukla

unread,
Mar 1, 2011, 12:49:42 PM3/1/11
to knowledge-...@googlegroups.com
@ neha n raveena
jus read the above syntax once again n then dry run the followin example...

#include <memory.h>

#include <stdio.h>

 

void main( void )

{

   char buffer[] = "This is a test of the memset function";

 

   printf( "Before: %s\n", buffer );

   memset( buffer, '*', 4 );

   printf( "After:  %s\n", buffer );

}

 

 

Output

Before : This is a test of the memset function

After :  ****  is a test of the memset function

bas particular characters reset ho rahe hai m/r se. nthin else..
Hope it is clear nw :)

Neha

unread,
Mar 1, 2011, 12:53:13 PM3/1/11
to Knowledge Test
thanx akanksha......

Ravina soni

unread,
Mar 1, 2011, 1:33:06 PM3/1/11
to knowledge-...@googlegroups.com



thanku its clear nw

Reply all
Reply to author
Forward
0 new messages