Code:
This is the satend program using Message Queues
/*
 * A message queue program that shows a client server implementation
 * this is the satend program using Message Queues
 */
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#define MAX_TEXT 512

struct my_msg_st 
{
        long int MType;
        char Text[MAX_TEXT];
};

int main()
{
 	int Inprocess = 1;
	int MSG_ID;
	char atend[3] = "end";
	struct my_msg_st Data;
	char Buff[BUFSIZ];
	system("clear");
	MSG_ID = msgget((key_t)1234, 0666 | IPC_CREAT);
	if (MSG_ID == -1) 
	{
	  fprintf(stderr,"Failed to get the message : %d ", errno);
	  exit(EXIT_FAILURE);
	}

 while(Inprocess) 
 {
printf("Entertext : ");
fgets(Buff, BUFSIZ, stdin);
	if (strncmp(Buff, atend,3) == 0 )
	{ Inprocess = 0; }
printf(" Text sent : %s ", Buff);
Data.MType = 1;
strcpy(Data.Text, Buff);


	if (msgsnd(MSG_ID, (void *)&Data, MAX_TEXT, 0) == -1) 
	{
	 
	fprintf(stderr,"sending failed ");
	  exit(EXIT_FAILURE);
	}

}	
	exit(EXIT_SUCCESS);
}