OK, starting inside main() you have only 2 lines.
The first one allocates space for a variable of type struct stack. The second one passes the address of your variable to the function initstack().
struct stack st;
All you're doing is passing an address to a function. Here's the function definition:
All this does is take a pointer to a variable of type struct stack. A pointer just contains the address of a variable.
void initstack(struct stack*st) // having trouble understanding this part.
st->top = 0;
Therefore, the lone statement inside the function actually alters the struct that was passed to it because its address was passed. The statement above is equivalent to the following:
Because st inside this function is a pointer, you need to derefence it.
Forgetting structs for a moment, the pointer aspect of it is just like this:
If you realize the pointer relationship with regular variables, then it's just a matter of applying the concept over to structs.
void someFunction(int *);
void someFunction(int *p)
*p = 0;
Edit: Yes.... I'm getting slow in my old age.