This commit is contained in:
Imbus 2025-11-14 20:59:40 +01:00
parent b5b554bf31
commit 561a344f30
3 changed files with 68 additions and 0 deletions

15
getopt/getopt.c Normal file
View file

@ -0,0 +1,15 @@
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
int opt;
while ((opt = getopt(argc, argv, "hf:o:")) != -1) {
switch (opt) {
case 'h': puts("Help"); break;
case 'f': printf("File: %s\n", optarg); break;
case 'o': printf("Output: %s\n", optarg); break;
default: fprintf(stderr, "Usage: %s [-h] [-f file] [-o output]\n", argv[0]); return 1;
}
}
return 0;
}