Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Read <code>man getopt</code> <a href="http://linux.die.net/man/3/getopt" rel="noreferrer">http://linux.die.net/man/3/getopt</a></p> <blockquote> <p>optstring is a string containing the legitimate option characters. If such a character is followed by a colon, the option requires an argument, so getopt() places a pointer to the following text in the same argv-element, or the text of the following argv-element, in optarg. Two colons mean an option takes an optional arg; if there is text in the current argv-element (i.e., in the same word as the option name itself, for example, "-oarg"), then it is returned in optarg, otherwise optarg is set to zero.</p> </blockquote> <p>A sample code:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;unistd.h&gt; int main (int argc, char *argv[]) { int opt; while ((opt = getopt (argc, argv, "i:o:")) != -1) { switch (opt) { case 'i': printf ("Input file: \"%s\"\n", optarg); break; case 'o': printf ("Output file: \"%s\"\n", optarg); break; } } return 0; } </code></pre> <p>Here in the <code>optstring</code> is "i:o:" the colon ':' character after each character in the string tells that those options will require an argument. You can find argument as a string in the <code>optarg</code> global var. See manual for detail and more examples.</p> <p>For more than one character option switches, see the long options <code>getopt_long</code>. Check the manual for examples.</p> <p><strong>EDIT</strong> in response to the single '-' long options:</p> <p>From the man pages</p> <blockquote> <p>getopt_long_only() is like getopt_long(), but '-' as well as "--" can indicate a long option. If an option that starts with '-' (not "--") doesn't match a long option, but does match a short option, it is parsed as a short option instead.</p> </blockquote> <p>Check the manual and try it.</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. 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