Given the following code:

#include <stdio.h>

int main()
{
    int *p;
    p = (int *)malloc(10 * sizeof(int));

    while(1);
    return 0;
}

When the above code is compiled and run, and is interrupted while in execution by pressing Ctrl+C, how is the memory allocated to p freed? What is the role of the Operating System here? And how is it different from that in case Of C++, done using the new operator?

Edit
Report