Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can get it working on Windows by removing the &lt;unistd.h&gt; include and eliminating your use of the <a href="http://www.opengroup.org/onlinepubs/000095399/functions/getopt.html" rel="nofollow noreferrer">getopt()</a> function... you will have to parse the commandline manually or use <a href="http://www.boost.org/doc/libs/1_42_0/doc/html/program_options.html" rel="nofollow noreferrer">boost::program_options</a>.</p> <p>The header &lt;unistd.h&gt; and the the getopt() function are both available on UNIX-compliant operating systems, but not available on Windows (which is flagrantly non-compliant). If you want to be able to compile without any source code changes, you might also try downloading and installing <a href="http://www.cygwin.com/" rel="nofollow noreferrer">Cygwin</a>, which attempts to provide a UNIX-compliant environment inside of Windows with a modicum of success (though it isn't perfect, by any means). Alternatively, in the future, you can use a cross-platform library such as <a href="http://www.boost.org/" rel="nofollow noreferrer">Boost</a> or <a href="http://qt.nokia.com/" rel="nofollow noreferrer">Qt</a>.</p> <p><b>Manual Parsing</b><br /> Based on your usage message, you could replace the while-loop with the following code:</p> <pre> int idx=1; while ( idx &lt; argc ){ std::string arg(argv[idx]); if (arg == "-m"){ //minsup idx++; if (idx&gt;argc){ std::cerr&lt;&lt;"Option \""&lt;&lt;arg&lt;&lt;"\" requires parameter."&lt;&lt;std::endl; usage(argv[0]); // move usage message into a function std::exit(1); } minsup=atoi(argv[idx++]); }else if (arg == "-M"){ //minpat idx++; if (idx&gt;argc){ std::cerr&lt;&lt;"Option \""&lt;&lt;arg&lt;&lt;"\" requires parameter."&lt;&lt;std::endl; usage(argv[0]); // move usage message into a function std::exit(1); } minpat=atoi(argv[idx++]); }else if (arg == "-L"){ //maxpat idx++; if (idx&gt;argc){ std::cerr&lt;&lt;"Option \""&lt;&lt;arg&lt;&lt;"\" requires parameter."&lt;&lt;std::endl; usage(argv[0]); // move usage message into a function std::exit(1); } maxpat=atoi(argv[idx++]); }else if (arg == "-a"){ all=true; idx++; }else if (arg == "-w"){ where=true; idx++; }else if (arg == "-v"){ verbose=true; idx++; }else if (arg == "-t"){ //type idx++; if (idx&gt;argc){ std::cerr&lt;&lt;"Option \""&lt;&lt;arg&lt;&lt;"\" requires parameter."&lt;&lt;std::endl; usage(argv[0]); // move usage message into a function std::exit(1); } type=argv[idx++]; }else if (arg == "-d"){ idx++; if (idx&gt;argc){ std::cerr&lt;&lt;"Option \""&lt;&lt;arg&lt;&lt;"\" requires parameter."&lt;&lt;std::endl; usage(argv[0]); // move usage message into a function std::exit(1); } delimiter=argv[idx++]; }else { usage(); std::exit(1); } } </pre> <p>Then add the following code somewhere before your main function:</p> <pre> void usage(const char* progname) { std::cout &lt;&lt; "Usage: " &lt;&lt; progname &lt;&lt; " [-m minsup] [-M minpat] [-L maxpat] [-a] [-w] [-v] [-t type] [-d delimiter]" &lt; data .." &lt;&lt; endl; } </pre> <p>Note that this is slightly different from how getopt actually behaves (getopt would allow you to combine -awv together, whereas this parsing won't... but if that isn't important, then this should get the job done.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload