Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / System programming / Practice03 / ex4.c
diff options
context:
space:
mode:
1 files changed, 13 insertions, 0 deletions
-rw-r--r--Year 3/System programming/Practice03/ex4.c13
diff --git a/Year 3/System programming/Practice03/ex4.c b/Year 3/System programming/Practice03/ex4.c
new file mode 100644
index 0000000..0358e6c
--- /dev/null
+++ b/Year 3/System programming/Practice03/ex4.c
@@ -0,0 +1,13 @@
+#include <unistd.h> // link, unlink
+#include <stdio.h> // perror
+
+int main(int argc, char* argv[]) {
+ if(link(argv[1], argv[2]) < 0) {
+ perror("link");
+ return 1;
+ }
+ if(unlink(argv[1]) < 0) {
+ perror("unlink");
+ return 2;
+ }
+}