我寫的定向管涉及兒童和家長之間的溝通交流計劃每個未申報的標識符只報告一次?
這裏是我的代碼部分:
char writemsg[BUFFER_SIZE] = "Sugar Lover";
char readmsg[BUFFER_SIZE];
char parrecieve[BUFFER_SIZE];
char childrecieve[BUFFER_SIZE+1];
int fd[2];
int fd2[2];
pid_t pid;
if (pipe(fd) == -1|| pipe(fd2) == -1) {
printf("Pipe failed");
return 1;
}
pid = fork();
if (pid < 0) { /* error occurred */
printf("Fork Failed");
return 1;
}
if (pid > 0) { /* parent process */
int i =0;
close(fd[READ_END]);/* close the unused end of the pipe */
while(writemsg[i] !='\0'){
write(fd[WRITE_END],&writemsg[i] , sizeof(char));
i++;
}
close(fd[WRITE_END]);
i = 0;
close(fd2[WRTIE_END]);
while(read(fd2[READ_END], &parrecieve[i], sizeof(char))!=0){
printf("%c", parrecieve[i]);
i++;
}
close(fd2[READ_END]);
}
它抱怨這行編譯時:
close(fd2[WRTIE_END]);
莫非
有人告訴我爲什麼?謝謝!
描述性標題! – 2013-09-21 18:43:41