include stdio.h include unistd.h include stdlib.h - PowerPoint PPT Presentation

1 / 1
About This Presentation
Title:

include stdio.h include unistd.h include stdlib.h

Description:

include stdio.h include unistd.h include stdlib.h – PowerPoint PPT presentation

Number of Views:189
Avg rating:3.0/5.0
Slides: 2
Provided by: deepen
Category:
Tags: argv | include | stdio | stdlib | unistd

less

Transcript and Presenter's Notes

Title: include stdio.h include unistd.h include stdlib.h


1
include ltstdio.hgtinclude ltunistd.hgtinclude
ltstdlib.hgtinclude ltstring.hgtmain(int argc,
char argv ) int f_des2
static char messageBUFSIZ if (argc ! 2)
fprintf(stderr, "Usage s message\n",
argv) exit(1) if (pipe(f_des) -1)
// generate the pipe perror("Pipe")
exit(2) switch (fork( )) case -1
perror("Fork") exit(3) case 0
// In the child
close(f_des1) if (read(f_des0, message,
BUFSIZ) ! -1) printf("Message received
by child s\n", message)
fflush(stdout) else
perror("Read") exit(4) break
default // In the Parent
close(f_des0) if
(write(f_des1, argv1, strlen(argv1)) ! -1)
printf("Message sent by parent
s\n", argv1) fflush(stdout)
else perror("Write") exit(5)
exit(0) 
Write a Comment
User Comments (0)
About PowerShow.com