malloc in c | dynamic memory allocation | by dubebox

Опубликовано: 03 Ноябрь 2024
на канале: The Digital Folks
45,882
2.1k

dynamic memory allocation - malloc in c

The name malloc stands for memory allocation.

The malloc function reserves a block of memory of the specified number of bytes. And, it returns a pointer of void type , which can be casted into pointers of any form.

Example -

I have allocated memory dynamically with the help of malloc for 100 blocks of memory.
Each block is having size of 4 bytes. Hence , total of 400 bytes of memory would be allocated.
And lastly, pointer typecast is required of integer type.







#malloc #shorts #bydubebox #cprogramming