Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / System programming / Practice06 / ex3.c
diff options
context:
space:
mode:
1 files changed, 16 insertions, 0 deletions
-rw-r--r--Year 3/System programming/Practice06/ex3.c16
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 <unistd.h> // pipe
+#include <stdio.h>
+
+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);
+}