This is not an ideal solution, but you can check the exact argument given by the user after calling getopt_long () (usually inside the switch), as shown below:
if (strcmp(argv[optind-1], "--longoption") == 0)
optind indicates the next argument you need to process. This way you can access the original argument using optind-1.
source
share