Add unlink

This commit is contained in:
Ali Furkan Yıldız 2022-10-04 15:21:00 +03:00
parent 32dc6db40b
commit 7f2ce1314e

24
c/unlink.c Normal file
View file

@ -0,0 +1,24 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
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