Other potential solutions (1)

GetOpt

An existing library for parsing command line options