In learning about stack and heap memory, the question I have is: why allocate memory? I’m a practical learner, so I prefer to understand what I’m learning as opposed to just doing it; so while I can reproduce the code and its effects, I’d like to know why we do it in the first place.
I understand that stack memory is temporary and heap memory is more or less permanent. I also believe I understand what pointers are for (persistent variables). What I don’t know is why we should use “alloc” or “malloc”.
I very much appreciate any help someone can provide. Thank you!