Diving into dynamic memory allocation

Report a typo

In operating systems, memory management takes care of several important tasks. Here is a C code snippet demonstrating a malloc function, which is often used for dynamic memory allocation. Can you identify the primary role of this function in the context of memory management?


#include 
int main() {
   int *ptr;
   ptr = (int*) malloc(15 * sizeof(int));
   if(ptr == NULL) {
      printf("Memory not allocated.\n");
      exit(0);
   }
}
Select one option from the list

Create a free account to access the full topic