First of all, in your code you are not initializing structure1 by structure2, but merely disguising pointer to structure2 as a pointer to structure1.
exams
structure instance apparently (let alone weird alignment settings) takes less memory than student instance
. Accessing pptr->name_id[9]
can very well result in reading past the area dedicated to e
. Now it all depends upon your compiler, your computer and so on.. meaning that it is better avoid delving into such details for one's sake.
The output of this code has to be zero
Perhaps it is if you are reading from unallocated stack area (past e
) and in your setup stack is filled with zeroes before handing it over to the running thread.
Please read more in your C book about casting and automatic memories and instances and pointers. There is really so much to tell to right your code. You would be better off asking more specific questions after you've studied on the topic more. Good luck