Originally Posted by
Todd Burch
We use malloc to get more memory! For onesies or twosies, there's not usually a point. For a 50 byte constant string, there's no point there either. Think on a bigger and more dynamic scale.
Let's say you have to read a 20MB file into memory and parse through it a few times. Do you really want to reserve 20MB in your program to do this? If you did, your .exe file is 20MB large, plus the size of your code, with might be 1K. (1,000 bytes, roughly).
Look at it this way. If your buddies wanted to download your program, it would be a 20.001MB download. However, if you used malloc() on your program, it would be a 1K download.
Todd