Untitled
public c v1 · immutable#include <popt.h>#include <stdio.h>#include <stdlib.h>char *foo = NULL;int main(int argc, const char *argv[]){ int cur_arg; poptContext context; struct poptOption option_table[] = { {NULL, 'q', POPT_ARG_STRING, &foo, 0, NULL, NULL}, POPT_TABLEEND }; context = poptGetContext(NULL, argc, argv, option_table, 0); while((cur_arg = poptGetNextOpt(context)) >= 0); poptFreeContext(context); if(foo != NULL) { puts(foo); free(foo); } return 0;}