c++ memset code example

Example 1: memset

/* memset example */
#include <stdio.h>
#include <string.h>

int main ()
{
  char str[] = "almost every programmer should know memset!";
  memset (str,'-',6);
  puts (str);
  return 0;
}

// Output:
// ------ every programmer should know memset!

Example 2: memset c++

memset(a, 0, sizeof(a)) 
memset(str, '#', sizeof(str));

Example 3: memset in cpp

/* memset example */
#include <stdio.h>
#include <string.h>

int main ()
{
  char str[] = "almost every programmer should know memset!";
  memset (str,'-',6);
  puts (str);
  return 0;
}

Output: ------ every programmer should know memset!

Example 4: memset

// memset syntax
void * memset ( void * ptr, int value, size_t num );

Tags:

C Example