What is malloc ?

Опубликовано: 26 Май 2026
на канале: Hitanshu Soni
462
7

`malloc` is a function used in programming to dynamically allocate memory on the heap during runtime. It stands for "memory allocation." When called, `malloc` reserves a specified amount of memory and returns a pointer to the starting address of the allocated block. This memory is not automatically initialized, and the responsibility to manage it lies with the programmer. After using the allocated memory, it must be explicitly freed using `free` to avoid memory leaks. `malloc` is widely used in C and C++ to create flexible data structures and manage memory efficiently for programs with unpredictable memory needs.