while((c = getopt(argc, argv, "f:d:h") != -1))
It works like
c = (getopt(argc, argv, "f:d:h") != -1)
Well, that is 1 always because the result of the comparison is stored to c
. In your case the getopt
does not return -1
. If it returns -1
then c
would be 0
. The fix is
while((c = getopt(argc, argv, "f:d:h")) != -1)