title: How to call correctly getopt function
body: <p>Errors while calling int getopt function from <a href="http://code.google.com/p/darungrim/source/browse/trunk/ExtLib/XGetopt.cpp?r=17" rel="nofollow">http://code.google.com/p/darungrim/source/browse/trunk/ExtLib/XGetopt.cpp?r=17</a> </p>
  
  <pre><code>`check.cpp: In function ‘int main()’:`
  </code></pre>
  
  <p><code>check.cpp:14:55: error: invalid conversion from ‘const char**’ to ‘char* const*’ [-fpermissive]</code></p>
  
  <p><code>/usr/include/getopt.h:152:12: error:   initializing argument 2 of ‘int getopt(int, char* const*, const char*)’ [-fpermissive]</code></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  #include &lt;string&gt;
  #ifdef USE_UNISTD
  #include &lt;unistd.h&gt;
  #else
  #include "XGetopt.h"
  #endif
  using namespace std;
  
  int main() {
  
  string text="-f  input.gmn -output.jpg";
  int argc=text.length();
  cout&lt;&lt;"argc: "&lt;&lt;argc&lt;&lt;endl;
  char const * argv = text.c_str();
  cout&lt;&lt;"argv: "&lt;&lt;argv&lt;&lt;endl;
  int c = getopt (argc, &amp;argv, "f:s:o:pw:h:z:t:d:a:b:?");
  cout&lt;&lt;"c: "&lt;&lt;c&lt;&lt;endl;
  return 0;
  }
  </code></pre>