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