snippets/c/unlink.c

25 lines
418 B
C
Raw Normal View History

2022-10-04 15:21:00 +03:00
#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
2023-01-11 19:27:37 +03:00
// Usage: ./unlink FILES...
// License: Public Domain