2015-06-06から1日間の記事一覧

gdbでgetopt()のoptind/optoptを参照したときに値が違うように見える

結構ハマったのでメモ。 #include <stdio.h> #include <getopt.h> char *short_opts = "ab:"; struct option long_opts[] = { {"test", no_argument, 0, 0}, {"add", required_argument, 0, 0}, {0, 0, 0, 0} }; int main(int argc, char *argv[]) { int c = 0; int longindex; </getopt.h></stdio.h>…