#include <unistd.h> #include <stdio.h> #include <stdlib.h> int main (int argc, char** argv) { int o; int opt_a; char* opt_c; while ((o = getopt (argc, argv, "abc:")) != -1) { switch (o) { case 'a': opt_a = 1; break; case 'c': opt_c = optarg; break; default: usage(); } } argc -= optind; argv += optind; // throw away option arguments }