Skip to content

Instantly share code, notes, and snippets.

@olastor
Created November 5, 2017 13:28
Show Gist options
  • Save olastor/37cb455734f4268a68a2dc9f00c0bfbc to your computer and use it in GitHub Desktop.
Save olastor/37cb455734f4268a68a2dc9f00c0bfbc to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
int main(int argc, char *argv[]) {
int c;
while((c = getopt(argc, argv, "ab:c:")) != -1) {
switch(c) {
case 'a':
printf("Flag 'a' set");
break;
case 'b':
printf("Parameter b: %s\n", optarg);
break;
case 'c':
printf("Parameter c: %s\n", optarg);
break;
default:
abort();
}
}
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment