From 7f2ce1314e6e141ad67cbe6f6f6e287b7d116656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Furkan=20Y=C4=B1ld=C4=B1z?= Date: Tue, 4 Oct 2022 15:21:00 +0300 Subject: [PATCH] Add unlink --- c/unlink.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 c/unlink.c diff --git a/c/unlink.c b/c/unlink.c new file mode 100644 index 0000000..c9cb016 --- /dev/null +++ b/c/unlink.c @@ -0,0 +1,24 @@ +#include +#include +#include +#include + +int main(int argc, char** argv) { + if (argc < 2) { + fprintf(stderr, "Not enough arguments."); + exit(1); + } + + for (int i = 1; i < argc; i++) { + int code = unlink(argv[i]); + if (code == -1) { + perror(argv[0]); + exit(1); + } + } + return 0; +} + +// Compilation: cc unlink.c -o unlink +// Usage: ./unlink FILES ... +// License: CC-0