There are many problems with your code. So let's start with the beginning and move towards a working solution.
First, you should always check the returned code from a system call, It it fails, prints error (e.g. using
perror()) and immediately exits. This gives you the opportunity to fix right away the problem instead of continuing with some error condition.
This is for instance the case in your first program with
ftok(). If this calls fails, you continue creating a queue with Id
-1 (0xffffffff) . As quoted in the man page:
Quote:
The ftok() function uses the identity of the file named by the given pathname (which must refer to an existing, accessible file) and the least significant 8 bits of proj_id [...]
Make sure that you fixed the points mentioned above. If you still have problems, we shall work them on.
Greets,
/Lew