
{"id":2892,"date":"2010-09-11T23:23:48","date_gmt":"2010-09-11T17:53:48","guid":{"rendered":"http:\/\/www.jeffrin.in\/?p=2892"},"modified":"2010-09-11T23:23:48","modified_gmt":"2010-09-11T17:53:48","slug":"struct-keyword","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2010\/09\/11\/struct-keyword\/","title":{"rendered":"struct keyword and getopt_long"},"content":{"rendered":"<p><a href=\"https:\/\/beautifulworknew.wordpress.com\/wp-content\/uploads\/2021\/03\/9fd32-getoptandstruct1.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/beautifulworknew.wordpress.com\/wp-content\/uploads\/2021\/03\/9fd32-getoptandstruct1.png?w=300\" alt=\"\" title=\"getoptandstruct\" width=\"300\" height=\"225\" class=\"alignnone size-medium wp-image-2902\" \/><\/a><\/p>\n<pre>\nThe  getopt() function parses the command-line arguments.  Its\narguments argc and argv are the argument count and\narray as passed to the main() function on program invocation.\nAn element of argv that starts with  '-'  (and  is not  exactly\n\"-\" or \"--\") is an option element.  The characters of this\nelement (aside from the initial '-') are option characters.\nIf getopt() is called repeatedly, it returns successively each\nof the option characters  from each of the option elements.\n<\/pre>\n<pre>\nlongopts is a pointer to the first element of an array of struct option\ndeclared in &lt;getopt.h&gt; as\n\n           struct option {\n               const char *name;\n               int         has_arg;\n               int        *flag;\n               int         val;\n           };\n\n<\/pre>\n<h5> Example Code <\/h5>\n<p><code><br \/>\n static const struct option long_options[] =<br \/>\n        {<br \/>\n                {\"domain\", no_argument, 0, 'd'},<br \/>\n                {\"boot\", no_argument, 0, 'b'},<br \/>\n                {\"file\", required_argument, 0, 'F'},<br \/>\n                {\"fqdn\", no_argument, 0, 'f'},<br \/>\n                {\"all-fqdns\", no_argument, 0, 'A'},<br \/>\n                {\"help\", no_argument, 0, 'h'},<br \/>\n                {\"long\", no_argument, 0, 'f'},<br \/>\n                {\"short\", no_argument, 0, 's'},<br \/>\n                {\"version\", no_argument, 0, 'V'},<br \/>\n                {\"verbose\", no_argument, 0, 'v'},<br \/>\n                {\"alias\", no_argument, 0, 'a'},<br \/>\n                {\"ip-address\", no_argument, 0, 'i'},<br \/>\n                {\"all-ip-addresses\", no_argument, 0, 'I'},<br \/>\n                {\"nis\", no_argument, 0, 'y'},<br \/>\n                {\"yp\", no_argument, 0, 'y'},<br \/>\n                {0, 0, 0, 0}<br \/>\n        };<\/p>\n<p><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The getopt() function parses the command-line arguments. Its arguments argc and argv are the argument count and array as passed to the main() function on program invocation. An element of argv that starts with &#8216;-&#8216; (and is not exactly &#8220;-&#8221; or &#8220;&#8211;&#8220;) is an option element. The characters of this element (aside from the initial &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2010\/09\/11\/struct-keyword\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;struct keyword and getopt_long&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[514,995,1005,1313,1505],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/2892"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=2892"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/2892\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=2892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=2892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=2892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}