V
Vince C.
Hi.
I'm writing a C++ application that uses GNU getopt_long() to parse command
line argument syntaxes.
http://www.gnu.org/software/libc/manual/html_node/Getopt-Long-Options.html
I'd like to check multiple syntaxes hence multiple arrays of items, which
type are "option", defined in "getopt.h":
struct option {
const char *name;
int has_arg;
int *flag;
int val;
};
Since I want to make my program generic, I've used a vector<option> to
dynamically build an array of options, which I need to pass to function
getopt_long():
vector<option> options;
int getopt_long (int argc, char *const *argv, const char *shortopts, const
struct option *longopts, int *indexptr)
My program sucessfully back pushes option items into the vector but
getopt_long() doesn't seem to react as expected. Since I have no access to
the vector array data, I just pass &options[0] as the 4th argument,
longopts.
Can I be sure &options[0] is actually the address of the beginning of the
array? In other terms, does vector operator [] return the real adress of an
element in its container?
Thanks in advance.
I'm writing a C++ application that uses GNU getopt_long() to parse command
line argument syntaxes.
http://www.gnu.org/software/libc/manual/html_node/Getopt-Long-Options.html
I'd like to check multiple syntaxes hence multiple arrays of items, which
type are "option", defined in "getopt.h":
struct option {
const char *name;
int has_arg;
int *flag;
int val;
};
Since I want to make my program generic, I've used a vector<option> to
dynamically build an array of options, which I need to pass to function
getopt_long():
vector<option> options;
int getopt_long (int argc, char *const *argv, const char *shortopts, const
struct option *longopts, int *indexptr)
My program sucessfully back pushes option items into the vector but
getopt_long() doesn't seem to react as expected. Since I have no access to
the vector array data, I just pass &options[0] as the 4th argument,
longopts.
Can I be sure &options[0] is actually the address of the beginning of the
array? In other terms, does vector operator [] return the real adress of an
element in its container?
Thanks in advance.