dgquvn / repo

1 stars 1 forks source link

main() (or something) should check arguments #16

Closed jayjaybillings closed 7 years ago

jayjaybillings commented 7 years ago

main() or some other function should check the input arguments before attempting to use them. For example, running FizzBuzz_v2 with no arguments produces

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_M_construct null not valid
Aborted (core dumped)

but it should produce an easy to understand error message with instructions. For reference, see the information and example here: http://www.cplusplus.com/articles/DEN36Up4/

dgquvn commented 7 years ago

added boost/program_options and handling the errors

jayjaybillings commented 7 years ago

I didn't see it yet, but that could be my Android client.

dgquvn commented 7 years ago

There was some kind of error not updating at first. But it's there

dgquvn commented 7 years ago

This should also be closed now. Let me know if there is any need suggestions

jayjaybillings commented 7 years ago

It is customary to process options in a separate function completely. Your goal should be for main() to only call other functions and therefore be as short as possible. (Maybe only a single branch or loop.)