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. Both comments and pings are currently closed. Tweet This! Tweet This! or use to share this post with others.

Comments are closed.