title: Integers are set to random values after msgrcv
body: <p>I have a number of messages (which are integers) on the queue I want to consume and I want to keep track of how many messages I consume using an integer <code>int consumed</code>.</p>
  
  <p>I first detect if the queue has messages using <code>ds.msg_qnum &gt; 0</code> where ds is an object of struct msqid_ds. If there are messages then I call msgrcv to consume the message and increment the consumed counter.</p>
  
  <p>So I have this:</p>
  
  <pre><code>msgrcv(msgqid, (void *) &amp;message, sizeof(message), 1, 0)
  printf("consumed before incr: %d\n", consumed);
  consumed++;
  </code></pre>
  
  <p>And consumed shows up as the same random integer value after every message consumption. Also, I set my message struct to hold message data as type int; I am not sure if that is the smoking gun.</p>