All pastes #902970 Raw Edit

Stuff

public c v1 · immutable
·published 2008-02-13 22:05 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <sys/msg.h>#include <string.h>#include <errno.h>#include "practical3.h"int main(int argc, char** argv) {	if (argc != 2) {		fprintf(stderr,"Usage: %s [queue_id]\n",argv[0]);		return -1;	}	int queueid = atoi(argv[1]);	struct message_msgbuf *ourdata = malloc(sizeof(message_msgbuf));	printf("Reading queue ID: %d\n",queueid);	if (msgrcv(queueid, ourdata, sizeof(message_msgbuf), 0, 0) == -1) {		fprintf(stderr,"Error encountered: %s\n",strerror(errno));                free(outdata);		return 1;	} else {		printf("\tMessage type: %d\n\tMessage text: %s\n",ourdata->mtype, ourdata->message);                free(outdata);		return 1;	}}