Respuesta :

Answer:

In the following code, you can see the usage of malloc.

#include <stdio.h>

#include <stdlib.h>

int main(void) {

  int* numberPointer1 = NULL;

  int* numberPointer2 = NULL;

  numberPointer1 = (int *)malloc(sizeof(int *));

  numberPointer2 = (int *)malloc(sizeof(int *));

  *numberPointer1 = 44;

  *numberPointer2 = 99;

  printf("numberPointer1 = %d, numberPointer2 = %d\n", *numberPointer1, *numberPointer2);

  free(numberPointer1);

  free(numberPointer2);

  return 0;

}

Explanation:

Malloc allocates memory in the heap according to the input size and returns a pointer to the location where it was allocated, with an extra, it clears all allocated space.