{"id":600,"date":"2012-10-18T15:58:28","date_gmt":"2012-10-18T15:58:28","guid":{"rendered":"https:\/\/raspberry-projects.com\/pi\/?p=600"},"modified":"2016-01-21T16:42:33","modified_gmt":"2016-01-21T16:42:33","slug":"getting-arguments-supplied-to-the-program","status":"publish","type":"post","link":"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/arguments\/getting-arguments-supplied-to-the-program","title":{"rendered":"Getting Arguments Supplied To The Program"},"content":{"rendered":"<pre>\r\n<code>\r\nint main(int argc, char **argv)\r\n{\r\n\tif (argc &lt; 2) \/\/Check enough arguments we&#39;re supplied\r\n\t{\r\n\t\tfprintf(stderr, &quot;You didn&#39;t supply enough aruuments\\n&quot;);\r\n\t\texit(EXIT_FAILURE);\r\n\t}\r\n\t\r\n\t\/\/Check the arguments\r\n\tint i;\r\n\tfor(i = 1; i &lt;argc; i++)\t\/\/argc is always &gt;=1 as the first argument is always the programs name\r\n\t{\r\n\t\t++argv;\r\n\t\tif (strncmp(*argv, &quot;somevalue1&quot;, 100) == 0)\r\n\t\t{\r\n\t\t}\t\r\n\r\n\t\tif (strncmp(*argv, &quot;somevalue2&quot;, 100) == 0)\r\n\t\t{\r\n\t\t}\r\n\r\n\t\tif (strncmp(*argv, &quot;somevalue3&quot;, 100) == 0)\r\n\t\t{\r\n\t\t}\r\n\t}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>int main(int argc, char **argv) { if (argc &lt; 2) \/\/Check enough arguments we&#39;re supplied { fprintf(stderr, &quot;You didn&#39;t supply enough aruuments\\n&quot;); exit(EXIT_FAILURE); } \/\/Check the arguments int i; for(i = 1; i &lt;argc; i++) \/\/argc is always &gt;=1 as the first argument is always the programs name { ++argv; if (strncmp(*argv, &quot;somevalue1&quot;, 100) == [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[],"class_list":["post-600","post","type-post","status-publish","format-standard","hentry","category-arguments"],"_links":{"self":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/600","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/comments?post=600"}],"version-history":[{"count":6,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/600\/revisions"}],"predecessor-version":[{"id":2478,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/600\/revisions\/2478"}],"wp:attachment":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/media?parent=600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/categories?post=600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/tags?post=600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}