Microcontroller › AVR › Structures and Memory › malloc() is a method used for
December 12, 2013 at 4:23 am
#10727
Participant
malloc() is a method used for dynamic memory allocation. malloc() creates a block of memory whenevr that function is called and in our case we are pointing our structure pointer to that memory block.
“Every pointer needs to be pointed to a memory before it is accessed”.
In this case the memory of the size of the structure will get allocated only after the malloc() is called. Once you’ve done, you can remove that memory using the function free().
Suggest you to google it for a good tutorial
http://www.codingunit.com/c-tutorial-the-functions-malloc-and-free
http://www.cprogramming.com/tutorial/c/lesson6.html
Still having doubts, please feel free to post here.