User Tools

Site Tools


c:getopt
#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
}
c/getopt.txt · Last modified: 2009/08/13 09:49 by tkbletsc

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki