Answers for "malloc in c++ geeksforgeeks"

C++
4

malloc in c

#include <stdlib.h>

void *malloc(size_t size);

void exemple(void)
{
  char *string;
  
  string = malloc(sizeof(char) * 5);
  if (string == NULL)
    return;
  string[0] = 'H';
  string[1] = 'e';
  string[2] = 'y';
  string[3] = '!';
  string[4] = '';
  printf("%sn", string);
  free(string);
}

/// output : "Hey!"
Posted by: Guest on March-03-2020
0

malloc c++ program

void* malloc(size_t size);
Posted by: Guest on November-05-2020

Browse Popular Code Answers by Language