From a607349b22f8a201512582e6341fe020527baf62 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 2 Dec 2023 21:48:54 +0200 Subject: [SP/P06] Solved most exercises --- Year 3/System programming/Practice06/ex3.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Year 3/System programming/Practice06/ex3.c (limited to 'Year 3/System programming/Practice06/ex3.c') diff --git a/Year 3/System programming/Practice06/ex3.c b/Year 3/System programming/Practice06/ex3.c new file mode 100644 index 0000000..a1ef2e2 --- /dev/null +++ b/Year 3/System programming/Practice06/ex3.c @@ -0,0 +1,16 @@ +#include // pipe +#include + +int main(int argc, char* argv[]) { + int filedes[2]; + if (pipe(filedes) < 0) { + perror("pipe"); + return 1; + } + + char buf = 'a'; + write(filedes[0], &buf, 1); + char bufin; + read(filedes[1], &bufin, 1); + printf("%c\n", bufin); +} -- cgit v1.3.1-26-gb76a