{"id":7020,"date":"2018-08-09T20:23:23","date_gmt":"2018-08-09T11:23:23","guid":{"rendered":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=7020"},"modified":"2018-08-09T20:23:23","modified_gmt":"2018-08-09T11:23:23","slug":"c-%e3%81%ae-main-%e3%81%ae-argc-%e3%81%af%e3%82%bc%e3%83%ad%e3%81%ab%e3%81%aa%e3%82%8b%e3%81%93%e3%81%a8%e3%81%8c%e3%81%82%e3%82%8b","status":"publish","type":"post","link":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=7020","title":{"rendered":"C \u306e main \u306e argc \u306f\u30bc\u30ed\u306b\u306a\u308b\u3053\u3068\u304c\u3042\u308b"},"content":{"rendered":"<p>\u300c\u666e\u901a\u306b\u300d\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u8d77\u52d5\u3057\u305f\u5834\u5408\u306f\u30bc\u30ed\u306b\u306a\u308b\u3053\u3068\u306f\u306a\u3044\uff08=\u30bc\u30ed\u306b\u306a\u308b\u3088\u3046\u306a\u8d77\u52d5\u306e\u3057\u304b\u305f\u306f\u666e\u901a\u3057\u306a\u3044\uff09\u306e\u3067\u3059\u304c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b\u3068\u30bc\u30ed\u306b\u306a\u308a\u307e\u3059 (Linux) \u3002<\/p>\n<p><!--more--><\/p>\n<blockquote>\n<pre>\r\n[umezawa@umezawa-dev:pts\/0 main_args]$ cat one.c\r\n#include &lt;stdio.h&gt;\r\n#include &lt;unistd.h&gt;\r\n#include &lt;errno.h&gt;\r\n#include &lt;string.h&gt;\r\n\r\nint main(void)\r\n{\r\n        char* argv[] = { NULL };\r\n        char* envp[] = { NULL };\r\n\r\n        execve(\".\/two\", argv, envp);\r\n        printf(\"execve: %s\\n\", strerror(errno));\r\n        return 0;\r\n}\r\n[umezawa@umezawa-dev:pts\/0 main_args]$ cat two.c\r\n#include &lt;stdio.h&gt;\r\n#include &lt;unistd.h&gt;\r\n#include &lt;errno.h&gt;\r\n#include &lt;string.h&gt;\r\n\r\nint main(int argc, char** argv)\r\n{\r\n        printf(\"argc = %d\\n\", argc);\r\n        for (int i = 0; i &lt; argc; ++i)\r\n                printf(\"argv[%d] = %s\\n\", i, argv[i]);\r\n        return 0;\r\n}\r\n[umezawa@umezawa-dev:pts\/0 main_args]$ .\/one\r\nargc = 0\r\n<\/pre>\n<\/blockquote>\n<p>\u5b9f\u969b\u3001 C \u306e\u898f\u683c\u66f8\u3092\u898b\u308b\u3068\u3001<\/p>\n<blockquote>\n<ul>\n<li>The value of argc shall be nonnegative.<\/li>\n<li>If the value of argc is greater than zero, &#8230;<\/li>\n<\/ul>\n<\/blockquote>\n<p>\u307f\u305f\u3044\u306a\u3053\u3068\u304c\u66f8\u3044\u3066\u3042\u308a\u307e\u3059\u3002 C++ \u306e\u898f\u683c\u66f8\u3067\u3082\u540c\u7b49\u306e\u3053\u3068\u304c\u66f8\u3044\u3066\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>argc \u304c\u30bc\u30ed\u306b\u306a\u308b\u3053\u3068\u3092\u8003\u616e\u3057\u3066\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u304f\u3053\u3068\u306f\u3042\u307e\u308a\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u300c\u666e\u901a\u306b\u300d\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u8d77\u52d5\u3057\u305f\u5834\u5408\u306f\u30bc\u30ed\u306b\u306a\u308b\u3053\u3068\u306f\u306a\u3044\uff08=\u30bc\u30ed\u306b\u306a\u308b\u3088\u3046\u306a\u8d77\u52d5\u306e\u3057\u304b\u305f\u306f\u666e\u901a\u3057\u306a\u3044\uff09\u306e\u3067\u3059\u304c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b\u3068\u30bc\u30ed\u306b\u306a\u308a\u307e\u3059 (Linux) \u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-7020","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/7020","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7020"}],"version-history":[{"count":3,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/7020\/revisions"}],"predecessor-version":[{"id":7023,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/7020\/revisions\/7023"}],"wp:attachment":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7020"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}