The code below I'm using Posix C:
while ((opt = getopt(argc, argv, "a:p:h")) != -1)
How can I port this code to Windows C++ using an alternative function?
Thanks
Microsoft has provided a nice implementation (as well as some other helpers) inside the open source IoTivity project here you could possibly re-use (pending any licensing requirements you may have):
Take a look at the "src" and "include" directories here for "getopt.h/.c".
https://github.com/iotivity/iotivity/tree/master/resource/c_common/windows