{"id":6716,"date":"2019-03-17T10:09:56","date_gmt":"2019-03-17T01:09:56","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=6716"},"modified":"2019-03-17T17:50:23","modified_gmt":"2019-03-17T08:50:23","slug":"%e3%80%90c%e8%a8%80%e8%aa%9e%e3%80%91%e9%96%a2%e6%95%b0%e3%81%ae%e5%bc%95%e6%95%b0%e3%81%ab%e9%85%8d%e5%88%97%e3%82%92%e6%b8%a1%e3%81%99%e5%a0%b4%e5%90%88%ef%bc%88%e3%83%9d%e3%82%a4%e3%83%b3%e3%82%bf","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=6716","title":{"rendered":"\u3010C\u8a00\u8a9e\u3011\u300c\u914d\u5217\u300d\u5229\u7528\u306b\u304a\u3051\u308b\u6ce8\u610f\u70b9"},"content":{"rendered":"<p>\u672c\u8a18\u4e8b\u306f\u3001C\u8a00\u8a9e\u306b\u304a\u3051\u308b<span style=\"color: #ff0000;\"><strong>\u300c\u914d\u5217\u300d\u5229\u7528\u306b\u304a\u3051\u308b\u6ce8\u610f\u70b9\u306e\u307f<\/strong><\/span>\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n<p>\u914d\u5217\u81ea\u4f53\u306f\u96e3\u3057\u3044\u6587\u6cd5\u3067\u306f\u306a\u3044\u305f\u3081\u3001\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u306f\u5272\u611b\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3059\u3002<\/p>\n<h2>\u914d\u5217\u81ea\u8eab\u306f\u578b\u3067\u3042\u308b\u3002<\/h2>\n<p>C\u8a00\u8a9e\uff08\u4ed6\u306e\u8a00\u8a9e\u3067\u3082\u305d\u3046\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\uff09\u3067\u306f\u914d\u5217\u3082\u4e00\u3064\u306e<span style=\"color: #ff0000;\"><strong>\u30c7\u30fc\u30bf\u578b<\/strong><\/span>\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">int a[10];<\/pre>\n<h2>\u914d\u5217\u306f\u4ed6\u306e\u914d\u5217\u5909\u6570\u306b\u30b3\u30d4\u30fc\uff08\u4ee3\u5165\uff09\u3092\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u3002<\/h2>\n<p>\u914d\u5217\u306f\u4f8b\u3048\u3070\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u4ee3\u5165\u3092\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"lang:default decode:true\">int a[2] = {1,2};\r\nint b[2];\r\n\r\nb = a;<\/pre>\n<p>\u3082\u3057\u3001\u914d\u5217\u306e\u5185\u5bb9\u3092\u4ed6\u306e\u914d\u5217\u5909\u6570\u306b\u30b3\u30d4\u30fc\u3057\u305f\u3044\u5834\u5408\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u30b3\u30d4\u30fc\u5143\u306e\u914d\u5217\u304b\u3089\u5024\u3092\u4e00\u3064\u4e00\u3064\u53d6\u308a\u51fa\u3057\u3066\u3001\u30b3\u30d4\u30fc\u5148\u306e\u914d\u5217\u306b\u4ee3\u5165\u3059\u308b<\/strong><\/span>\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u305f\u3060\u3001\u3053\u306e\u65b9\u6cd5\u3060\u3068\u30e1\u30f3\u30c9\u30af\u30b5\u30a4\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u5225\u306e\u30e1\u30e2\u30ea\u9818\u57df\u306b\u30b3\u30d4\u30fc\u3057\u3066\u304f\u308c\u308b<span style=\"color: #ff0000;\"><strong>memcpy\u95a2\u6570<\/strong><\/span>\u3092\u4f7f\u3046\u306e\u304c\u4e00\u822c\u7684\u3067\u3057\u3087\u3046\u3002<\/p>\n<h3>\u306a\u305c\u4ee3\u5165\u3067\u304d\u306a\u3044\u306e\u304b\uff1f<\/h3>\n<p>\u914d\u5217\u81ea\u4f53\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u6dfb\u3048\u5b57\u306a\u3057\u306e\u5834\u5408\uff08\u4e0a\u8a18\u4f8b\u3067\u3044\u3048\u3070a\u306e\u307f\uff09\u3060\u3068\u30a2\u30c9\u30ec\u30b9(&amp;a[0])\u3092\u6307\u5b9a\u3057\u305f\u3053\u3068\u3068\u540c\u3058<\/strong><\/span>\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001b\u306e\u30a2\u30c9\u30ec\u30b9\u306ba\u306e\u30a2\u30c9\u30ec\u30b9\u3092\u4ee3\u5165\u3059\u308b\u3068\u3044\u3046\u3001<span style=\"color: #ff0000;\"><strong>\u30b3\u30d4\u30fc\u3067\u306f\u306a\u304f\u540c\u3058\u30a2\u30c9\u30ec\u30b9\u3092\u6307\u3057\u3066\u3044\u308b\u4e8c\u3064\u306e\u5909\u6570\u304c\u3067\u304d\u308b\u3068\u3044\u3046\u610f\u5473\u306e\u306a\u3044\u51e6\u7406\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u305f\u3081<\/strong><\/span>\u3067\u3059\u3002<\/p>\n<h2>\u95a2\u6570\u306e\u5f15\u6570\u306b\u914d\u5217\u3092\u6e21\u3059\u5834\u5408\u306e\u6ce8\u610f\u70b9\uff08\u30dd\u30a4\u30f3\u30bf\u6e21\u3057\uff09<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b<span style=\"color: #ff0000;\"><strong>\u914d\u5217\u3092\u5f15\u6570\u306b\u3068\u308b\u95a2\u6570<\/strong><\/span>\u304c\u3042\u3063\u305f\u3068\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">void func(int a[1]) {\r\n\ta[0] = 15;\r\n}\r\n\r\nint main()\r\n{\r\n\tint a[1];\r\n\ta[0] = 2;\r\n\r\n\t\/\/\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u3002\r\n\tfunc(a);\r\n\t\/\/\u7d50\u679c\u306f\u300115\u3068\u8868\u793a\u3055\u308c\u308b\u3002\r\n\tprintf(\"%d\\n\", a[0]);\r\n\r\n}<\/pre>\n<p>\u305d\u306e\u969b\u306b\u3001<span style=\"color: #ff0000;\"><strong>\u95a2\u6570\u306e\u547c\u3073\u51fa\u3057\u5148\u3067\u66f8\u304d\u63db\u308f\u3063\u305f\u914d\u5217\u306e\u5024\u304c\u3001\u547c\u3073\u51fa\u3057\u5143\u306e\u914d\u5217\u306b\u307e\u3067\u51e6\u7406\u7d50\u679c\u304c\u5f71\u97ff<\/strong><\/span>\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u57fa\u672c\u7684\u306b\u3001\u95a2\u6570\u306b\u6e21\u3057\u305f\u5909\u6570\u306f\u3001\u547c\u3073\u51fa\u3057\u5148\u3068\u547c\u3073\u51fa\u3057\u5143\u3067\u72ec\u7acb\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u547c\u3073\u51fa\u3057\u5143\u306b\u307e\u3067\u5f71\u97ff\u306f\u3057\u306a\u3044\u306f\u305a\u3067\u3059\u304c\u3001\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f\u3001\u95a2\u6570\u306b\u914d\u5217\u3092\u6e21\u3057\u305f\u969b\u306f\u3001\u914d\u5217\u306e\u30a2\u30c9\u30ec\u30b9\u3092\u6e21\u3057\u305f\u3068\u540c\u3058\u4e8b\u306b\u306a\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u5b9f\u969b\u306b\u4e0b\u8a18\u306e\u3088\u3046\u306a\u5909\u63db\u304c\u884c\u308f\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">void func(int* a) { \/\/\u2605\u2605\u2605\u2605\u2605\uff1a\u30dd\u30a4\u30f3\u30bf\u578b\u3092\u6e21\u3059\u306e\u3068\u540c\u3058\u3088\u3046\u306b\u8aad\u307f\u66ff\u3048\u3089\u308c\u308b\u3002(int* a\u3068int a[1]\u306f\u540c\u3058\u610f\u5473)\r\n\t*a = 15; \/\/\u2605\u2605\u2605\u2605\u2605\uff1a\u30dd\u30a4\u30f3\u30bf\u3067\u30e1\u30e2\u30ea\u306e\u5185\u5bb9\u3092\u66f8\u304d\u63db\u3048\u308b\u3088\u3046\u306b\u8aad\u307f\u66ff\u3048\u3089\u308c\u308b\u3002(a[0]\u3068*a\u306f\u540c\u3058\u610f\u5473)\r\n}\r\n\r\nint main()\r\n{\r\n\r\n\tint a[1];\r\n\ta[0] = 2;\r\n\r\n\t\/\/\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u3002\r\n\tfunc(&amp;a[0]); \/\/\u2605\u2605\u2605\u2605\u2605\uff1a\u914d\u5217\u306e\u5148\u982d\u30a2\u30c9\u30ec\u30b9\u3092\u6e21\u3059\u306e\u3068\u540c\u3058\u3088\u3046\u306b\u8aad\u307f\u66ff\u3048\u3089\u308c\u308b\u3002\r\n\t\/\/\u7d50\u679c\u306f\u300115\u3068\u8868\u793a\u3055\u308c\u308b\u3002\r\n\tprintf(\"%d\\n\", a[0]);\r\n\r\n}<\/pre>\n<p>\u3053\u306e\u4e8b\u8c61\u306e\u3053\u3068\u3092<span style=\"color: #ff0000;\"><strong>\u300c\u30dd\u30a4\u30f3\u30bf\u6e21\u3057\u300d<\/strong><\/span>\u3068\u8a00\u3063\u3066\u3001<span style=\"color: #ff0000;\"><strong>\u547c\u3073\u51fa\u3057\u5143\u95a2\u6570\u3068\u547c\u3073\u51fa\u3057\u5148\u95a2\u6570\u3067\u540c\u3058\u30e1\u30e2\u30ea\u756a\u5730\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u5909\u6570\u306e\u4e2d\u3092\u66f8\u304d\u63db\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u308b<\/strong><\/span>\u306e\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u672c\u8a18\u4e8b\u306f\u3001C\u8a00\u8a9e\u306b\u304a\u3051\u308b\u300c\u914d\u5217\u300d\u5229\u7528\u306b\u304a\u3051\u308b\u6ce8\u610f\u70b9\u306e\u307f\u8a18\u8f09\u3057\u307e\u3059\u3002 \u914d\u5217\u81ea\u4f53\u306f\u96e3\u3057\u3044\u6587\u6cd5\u3067\u306f\u306a\u3044\u305f\u3081\u3001\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u306f\u5272\u611b\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3059\u3002 \u914d\u5217\u81ea\u8eab\u306f\u578b\u3067\u3042\u308b\u3002 C\u8a00\u8a9e\uff08\u4ed6\u306e\u8a00\u8a9e\u3067\u3082\u305d\u3046\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\uff09\u3067\u306f\u914d\u5217\u3082\u4e00 [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[74],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/6716"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6716"}],"version-history":[{"count":14,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/6716\/revisions"}],"predecessor-version":[{"id":6734,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/6716\/revisions\/6734"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6716"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}