Vivek Goel
Vivek Goel

Reputation: 24140

How to ignore invalid options in getopt_long

I am using function getopt_long to get command line options. I want to ignore error when a invalid option is given. Currently it printing error to stderr like:

 invalid option -- 's'

Upvotes: 2

Views: 3793

Answers (1)

P.P
P.P

Reputation: 121387

There's variable opterr in unistd.h which will avoid printing the the error to stderr if you set it to 0.

Just set it to 0:

#include <unistd.h>

opterr = 0;

Upvotes: 5

Related Questions