I dont get why do you have to do both. Isnt malloc creating dynamic memory for you? Then why do we have to state for example "int " in the beginning when later i will be mallocing that variable. Im new to malloc, sorry if this question has an obvious answer.
Example:
In the main :
int *p;
Then later in the function:
int *p = malloc(1000 * sizeof(int));