C memset function

« Previous

Synopsis:

Example

#include <stdio.h>
void* memset(void* s, int c, int n); 

Description:

The memset function sets the first n bytes in s to c. Generally this function is used to set a memory location to null chracters '\0'.

Return Value

The memset function returns s with the set value to c

Example

Example

#include <stdio.h>
int main() {
  char string[20];
  strcpy(string, "Learn");
  printf( "Before using memset |%s|\n", string );
  memset( string, '\0', sizeof(string) );
  printf( "After using memset |%s|\n", string );
  return 0;
}

Output Will Be :

Output

Before using memset |NewFile.|
After using memset ||


« Previous
Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!