Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 1
How and when do i use malloc?
I understand the concept behind malloc but i dont understand when to use it
1 Answer
+ 4
generally when you need to handle dynamic data that the size is not known during coding and compilation.
e.g. with records we don't know how many a user will input hence it being dynamic
else when you need to allocate a few memory spaces which C usually does for you anyway (if you know assembly then this will make more sense)