PREV INDEX NEXT

Author: Unknown
Subject: Question Regarding Command Line Args
Date: Tuesday, 11 Feb 2020, 22:41:54

Hi Professor,

I was testing your Binpack: 
% ./Binpack 10 4 -opt -ff 44 abcde

and noticed that it prints 
-opt 1
-ff 1
44 invalid flag

I reread the specifications and it states that the given command-line arguments should be % ./Binpack BIN_SIZE [ITEM_SIZE]* [-opt | -ff | -bf | -ffd | -bfd]*

The spec also states that [-opt | -ff | -bf | -ffd | -bfd]* should be a sequence of zero or more flags, each either -opt or -ff or -bf or -ffd or -bfd. 

Clearly, 44 and abcde are improper flags. Shouldn't the executable quit instead of process anything? Similarly, when I ran your Binpack as:

% ./Binpack 10 -opt 3 -ff

It printed 
-opt 0
3 invalid flag

However, 3 is not a proper flag.

Thank you.
PREV INDEX NEXT