Many things *could* be going wrong.
I guess the first step would be to modify your code to check for the return value from "msgrcv()":
iret = msgrcv (...);
PS: Please use "[code]" blocks - it definitely helps!
Here's a good tutorial (with sample code):
My book on SysV IPC's is undoubtedly out of print, but here's the reference anyway (it's a great book; it's served me well over the years):
Unix System Programming, Keith Haviland & Ben Salama, ISBN 0 201 129191