ggeettoopptt() -- General Function (libc)

Get option letter from argv
#iinncclluuddee <uunniissttdd.hh>
iinntt ggeettoopptt(_a_r_g_c, _a_r_g_v, _o_p_t_s_t_r_i_n_g)
iinntt _a_r_g_c;
cchhaarr **_a_r_g_v;
cchhaarr *_o_p_t_s_t_r_i_n_g;
eexxtteerrnn cchhaarr *_o_p_t_a_r_g;
eexxtteerrnn iinntt _o_p_t_i_n_d;

ggeettoopptt() returns  the next option letter  in aarrggvv that matches  a letter in
_o_p_t_s_t_r_i_n_g. _o_p_t_s_t_r_i_n_g is a string of recognized option letters.  If a letter
is followed by a colon, the  option must have an argument, which may or may
not be separated from it by white space.  _o_p_t_a_r_g points to the start of the
option argument on return from ggeettoopptt().

ggeettoopptt()  writes into  _o_p_t_i_n_d the  aarrggvv index  of the  next argument  to be
processed.  Because  _o_p_t_i_n_d is external, it is  normally initialized to one
automatically before the first call to ggeettoopptt().

When  all options  have been  processed (i.e., up  to the  first non-option
argument), ggeettoopptt() returns EOF.  The  special option ``--'' may be used to
delimit the end of the options: ggeettoopptt() returns EOF and skip ``--''.

_S_e_e _A_l_s_o
lliibbcc

_D_i_a_g_n_o_s_t_i_c_s
ggeettoopptt()  prints an  error  message and  returns  a question  mark when  it
encounters an option letter not included in _o_p_t_s_t_r_i_n_g.

_N_o_t_e_s
It is not  obvious how `-' standing alone should  be treated.  This version
treats it as a non-option argument, which is not always right.

Option arguments  are allowed to  begin with `-'.  This  is reasonable, but
reduces the amount of error checking possible.

ggeettoopptt() returns the parsed letter option in the external iinntt ooppttoopptt, which
is overwritten by each call to  ggeettoopptt(). When ggeettoopptt() returns `?', it can
be helpful to examine the contents of this variable.
