C Reference String Operation: memset()
The function memset() copies x into a buffer y and does this n times.
Usage:
void *memset( void *y, int x, size_t n);
Note: memset can be used to set all values of an array to zero (very efficient!)
An example: memset( an_array, ‘\0′, sizeof_array)
memchr() source code example:
#include<stdio.h>
#include<string.h>
main()
{
char line[100];
strcpy(line, "aacc");
memset(line,'b',2);
printf("%s\n", line);
}
Output of the example:
bbcc
This entry was posted in C Reference string.h Functions.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Tweet This! or use
to share this post with others.