home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_08_11
/
8n11053a
< prev
next >
Wrap
Text File
|
1990-09-18
|
754b
|
38 lines
func()
{
int msqid, msglen;
char string[80];
struct mssg {
long mtype;
char mtext[BUFSIZ];
} msgbuf;
/* Prompt user for a message to send */
printf("Enter message: ");
gets(msgbuf.mtext);
/* Prompt user for a message type */
printf("Enter message type: ");
gets(string);
sscanf(string,"%ld",&(msgbuf.mtype));
/* Set the message length */
msglen=strlen(msgbuf.mtext);
/* Send the message. The kernel will put
* the process to sleep if the message queue
* is full.
*/
if (msgsnd(msqid, &msgbuf, msglen, 0) == -1) {
/* The perror(3C) function prints the
* text of the error number contained
* in the external integer errno.
*/
perror("msgsnd() failed: ");
exit(1);
}
}