You specify the amount of data you are putting in the queue with the third argument of mq_send. In your case it's:
ret=mq_send(mq,buf,sizeof(buf),0);
Assuming that buf is initialized somewhere along the lines of
float f[2];
void *buf = f;
Then the expression sizeof(buf)
means: the size of the pointer called "buf". While it may work on some architectures, the proper way would be
ret=mq_send(mq,buf,sizeof(float) * <number of elements>, 0);
which means, the size of a float, multiplied by the amount of floats stored in the array.
In which case you would put the whole array in the queue. You would also avoid the iteration and use only a constant number of messages, instead of a linear number.