C Reference String Operation: memset()

The function memset() copies x into a buffer y and does this n times.


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:


		char line[100];
		strcpy(line, "aacc");

		printf("%s\n", line);

Output of the example:


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! Tweet This! or use to share this post with others.

Leave a Reply: