logo

When to free memory in C

#define _CRTDBG_MAP_ALLOC #include <crtdbg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char* argv[]) { int* p = calloc(1, sizeof(int)); int* q = p; *q = -1; free(p); _CrtDumpMemoryLeaks(); return 0; }

Courses with this lesson