AAE-CNAS-Labs/Topic-5-Pipes/task_4_1.c

27 lines
466 B
C
Raw Permalink Normal View History

2021-03-24 18:52:27 +01:00
//
// Written for Computer Networks and Systems lab classes
// AUTHOR : Sergiusz Warga
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
int main() {
int pipefd[2];
if (pipe(pipefd) < 0){
fprintf(stderr,"Something went wrong!\n");
return -1;
}
int in = 42;
int out = 0;
write(pipefd[1], &in, sizeof(in));
read(pipefd[0], &out, sizeof(out));
close(pipefd[0]);
if (!(in-out)) printf("Pipe works just fine!\n");
return 0;
}