malloc(…) lets you create an array---or more generally, a "buffer"---of arbitrary size. That means you don't need to know the size when you write the code.