Dynamic memory allocation in C (malloc, free) - Printable Version +- QP School (https://qomplainerzschool.lima-city.de) +-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3) +--- Forum: C 18 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=32) +--- Thread: Dynamic memory allocation in C (malloc, free) (/showthread.php?tid=5094) |
Dynamic memory allocation in C (malloc, free) - Qomplainerz - 07-25-2023 malloc() is used to allocate memory dynamically, and free() is used to release memory when it's no longer needed. int *ptr = (int *)malloc(sizeof(int)); if (ptr != NULL) { *ptr = 10; printf("Value: %d\n", *ptr); // Output: 10 free(ptr); // Release memory } |