Required parameters with getopt_long () in C

Using C / C ++ getopt_long()can be used to parse command line arguments. Is it possible to tell the function that some of the parameters are required? For example, how can I say getopt_longthat parsing should throw an error if the call startServeris called without mentioning the port below?

./startServer -port 80

Note. I am not talking about parameter arguments as mandatory, but about the parameters themselves.

+5
source share
1 answer

getopt_long() is not part of the C language. This is a GNU invention that is available in some C implementations, but not all.

getopt_long() glibc ( Linux) , . , .

+5

All Articles