c++ - getop returns always 1 -
i want sue getopt argument list of console tool. when call tool below getopt returns 1 , doesn't mactch switch/case.
am doing wrong?
mytool -f farg -d darg int main(int argc, char** argv) { int c; while((c = getopt(argc, argv, "f:d:h") != -1)) { switch(c) { case'f': break; default: break; } }
while((c = getopt(argc, argv, "f:d:h") != -1)) it works like
c = (getopt(argc, argv, "f:d:h") != -1) well, 1 because result of comparison stored c. in case getopt not return -1. if returns -1 c 0. fix is
while((c = getopt(argc, argv, "f:d:h")) != -1)
Comments
Post a Comment