Vivek Goel
Vivek Goel

Reputation: 24160

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: 3806

Answers (1)

P.P
P.P

Reputation: 121427

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