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

27 lines
466 B
C

//
// 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;
}