A brief view:
As already said, a pointer is a variable that merely holds an address of a variable.
malloc() is a function that is used to allocate memory for your program on the fly at runtime. Arguments are plenty with regard to the correct way of using malloc(), but the basic idea is that you give it the amount of memory needed in bytes and it'll return to you a block of memory of that size if it is able to. If it is not able to, it returns NULL.
int a = 5; /*This is a variable of type int that has a value of 5.*/
int *p = &a; /* This is a variable of type pointer to int that has the value of the address of a.*/
The above code segment tries to allocate a block of memory that is just enough to hold an int, and then assigns it to q. If not enough memory was available, q will be set to NULL.
int *q = malloc(sizeof(*q));
A more detailed view: