{"id":6750,"date":"2019-03-17T18:32:04","date_gmt":"2019-03-17T09:32:04","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=6750"},"modified":"2023-05-06T10:27:05","modified_gmt":"2023-05-06T01:27:05","slug":"%e3%80%90c%e8%a8%80%e8%aa%9e%e3%80%91%e3%80%8c%e3%83%8a%e3%83%ab%e6%96%87%e5%ad%97%e3%80%8d%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=6750","title":{"rendered":"\u3010C\u8a00\u8a9e\u3011\u300c\u30ca\u30eb\u6587\u5b57\u300d\u306b\u3064\u3044\u3066"},"content":{"rendered":"<h2>\u30ca\u30eb\u6587\u5b57\u3068\u306f\uff1f<\/h2>\n<p>C\u8a00\u8a9e\u306e\u6587\u5b57\u5217\u306fchar\u578b\u306e\u914d\u5217\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u305d\u306e\u7d42\u7aef\u6587\u5b57\u306b<span style=\"color: #ff0000;\"><strong>\u300c\u30ca\u30eb\u6587\u5b57\uff08\\0\uff09\u300d<\/strong><\/span>\u3092\u4f7f\u3044\u307e\u3059\u3002\u3061\u306a\u307f\u306b\u3001\u30b3\u30f3\u30d1\u30a4\u30e9\u304c\u81ea\u52d5\u3067\u5165\u308c\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>\u30ca\u30eb\u6587\u5b57\u306f\u8981\u306f<span style=\"color: #ff0000;\"><strong>\u300c\u5024\u304c\u30bc\u30ed\u3067\u3042\u308bint\u578b\u300d<\/strong><\/span>\u3068\u540c\u3058\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\uff08\\0\u306fNULL\u306e\u3053\u3068\u3092\u6307\u3057\u3066\u304a\u308a\u3001ASCII\u30b3\u30fc\u30c9\u306e\u5236\u5fa1\u6587\u5b57\u306e\u3053\u3068\u3092\u3055\u3057\u3066\u3044\u3066\u5b9f\u4f53\u306f\u6574\u6570\u306e0\u3068\u540c\u3058\u3068\u3044\u3046\u3053\u3068\u3002\uff09<\/p>\n<h3>\u4f8b<\/h3>\n<pre class=\"lang:default decode:true\">char str[4] = \"abc\";\r\n['a', 'b', 'c', '\\0']<\/pre>\n<p>\u3068\u3044\u3046char\u306e\u914d\u5217\u306b\u306a\u308a\u307e\u3059\u3002\u6700\u5f8c\u306e\u300c'\\0'\u300d\u304c\u30ca\u30eb\u6587\u5b57\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\u3053\u306e\u30ca\u30eb\u6587\u5b57\u3092\u610f\u56f3\u7684\u306b\u6d88\u3057\u3066\u3057\u307e\u3063\u305f\u5834\u5408(\u4e0a\u8a18\u4f8b\u3067\u8a00\u3048\u3070\u3001str[3]=\"d\"\u306a\u3069\u3068\u4ee3\u5165\u3057\u305f\u5834\u5408\u306b\u6d88\u3048\u3066\u3057\u307e\u3044\u307e\u3059\u3002)\u306fchar\u914d\u5217\u3092\u8868\u793a\u3055\u305b\u3088\u3046\u3068\u3057\u305f\u5834\u5408\u306b\u3072\u305f\u3059\u3089\u305a\u3063\u3068\u4e0d\u660e\u306a\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u307e\u305b\u308b\u3088\u3046\u306a\u6319\u52d5\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u6ce8\u610f\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001char\u914d\u5217\u3092for\u6587\u3067\u56de\u3059\u3088\u3046\u306a\u4ee5\u4e0b\u306e\u51e6\u7406\u306e\u5834\u5408\u306b\u30ca\u30eb\u6587\u5b57\u304c\u306a\u3044\u3068\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\uff08\u914d\u5217\u5916\u306e\u30e1\u30e2\u30ea\u30a2\u30af\u30bb\u30b9\u9055\u53cd\u304c\u767a\u751f\u3057\u3066\u7570\u5e38\u7d42\u4e86\u3057\u307e\u3059\u3002\uff09<\/p>\n<pre class=\"lang:default decode:true\">for (i = 0;str[i] != '\\0'; i++) {\r\n   src[i];\r\n}<\/pre>\n<p>\u307e\u305f\u3001C\u8a00\u8a9e\u3067\u306f\u30ca\u30eb\u6587\u5b57\u304c\u7d42\u7aef\u3067\u3042\u308b\u3053\u3068\u3092\u5229\u7528\u3057\u305f\u95a2\u6570\u306a\u3069\u304c\u3042\u308a\u305d\u308c\u3082\u7570\u5e38\u306a\u6319\u52d5\u306b\u306a\u308a\u307e\u3059\u3002\uff08\u4f8b\uff1aprintf\u95a2\u6570\uff09<\/p>\n<h2>\u30cc\u30eb\u30dd\u30a4\u30f3\u30bf\u3068\u306e\u9055\u3044\u306f\uff1f<\/h2>\n<p>\u30cc\u30eb\u30dd\u30a4\u30f3\u30bf\u306f\u3001stdio.h\u306b\u3066\u30de\u30af\u30ed\u5b9a\u6570\u3067\u300c0\u300d\u3067\u521d\u671f\u5316\u3055\u308c\u3066\u3044\u308b\u306e\u3067<span style=\"color: #ff0000;\"><strong>\u300c\u30ca\u30eb\u6587\u5b57\u300d\u3068\u540c\u3058\u306a\u306e\u3067\u306f<\/strong><\/span>\u3068\u601d\u3046\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u6240\u306f\u7570\u306a\u308a\u307e\u3059\u304c\u3001\u30b3\u30f3\u30d1\u30a4\u30e9\u306e\u50cd\u304d\u306b\u3088\u3063\u3066\u5b9f\u8cea\u7684\u306b\u306f\u540c\u3058\u3088\u3046\u306b\u52d5\u3044\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001\u4f8b\u3048\u3070\u30dd\u30a4\u30f3\u30bf\u5909\u6570\u306bint\u578b\u306e3\u3092\u5165\u308c\u305f\u5834\u5408\u306f\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">int main()\r\n{\r\n\tint *b;\r\n\tb = 3; \/\/\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\r\n}<\/pre>\n<p>\u3057\u304b\u3057\u30010\u3092\u5165\u308c\u308b\u3068\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"lang:default decode:true\">int main()\r\n{\r\n\tint *b;\r\n\tb = 0; \/\/\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u306b\u306a\u3089\u306a\u3044\u3002\r\n}<\/pre>\n<p>\u8981\u306f\u3001\u30b3\u30f3\u30d1\u30a4\u30e9\u304c<span style=\"color: #ff0000;\"><strong>\u300c0\u300d\u3068\u3044\u3046\u5b9a\u6570\u3092\u30cc\u30eb\u30dd\u30a4\u30f3\u30bf\u3068\u3057\u3066\u7279\u5225\u6271\u3044\u3092\u3057\u3066\u3044\u308b<\/strong><\/span>\u306e\u3067\u3059\u3002<\/p>\n<p>\u51e6\u7406\u7cfb\u306e\u9055\u3044\u306b\u3088\u3063\u3066\u3082\u307b\u3068\u3093\u3069\u5909\u308f\u308a\u307e\u305b\u3093\u3002<\/p>\n<h2>\u6587\u5b57\u306e\u7d42\u7aef\u306b\u30cc\u30eb\u30dd\u30a4\u30f3\u30bf\u306f\u4f7f\u3048\u308b\u304b\uff1f<\/h2>\n<p>\u30ca\u30eb\u6587\u5b57\u3068\u30cc\u30eb\u30dd\u30a4\u30f3\u30bf\u306f\u540c\u3058\u300c0\u300d\u3092\u793a\u3057\u3066\u3044\u308b\u306e\u3067\u6587\u5b57\u306e\u7d42\u7aef\u306b\u30cc\u30eb\u30dd\u30a4\u30f3\u30bf\u3082\u4f7f\u3048\u308b\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u304c\u3001\u7d50\u8ad6\u304b\u3089\u7533\u3057\u307e\u3059\u3068<span style=\"color: #ff0000;\"><strong>\u4f7f\u308f\u306a\u3044\u65b9\u304c\u3088\u3044<\/strong><\/span>\u3067\u3057\u3087\u3046\u3002<\/p>\n<p><span style=\"color: #ff0000;\"><strong>\u51e6\u7406\u7cfb\u306b\u3088\u3063\u3066\u306f\u3001\u30cc\u30eb\u30dd\u30a4\u30f3\u30bf\u306f\u300c0\u300d\u4ee5\u5916\u3092\u793a\u3059\u3053\u3068\u304c\u3042\u308b\u305f\u3081<\/strong><\/span>\u3067\u3059\u3002\uff08\u3082\u3061\u308d\u3093\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u4e0a\u3067\u30cc\u30eb\u30dd\u30a4\u30f3\u30bf\u3068\u3057\u3066\u4f7f\u3044\u305f\u3044\u5834\u5408\u306f\u3001\u666e\u901a\u306b\u4f7f\u3048\u3070\u3088\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3002\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"\u30ca\u30eb\u6587\u5b57\u3068\u306f\uff1f C\u8a00\u8a9e\u306e\u6587\u5b57\u5217\u306fchar\u578b\u306e\u914d\u5217\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u305d\u306e\u7d42\u7aef\u6587\u5b57\u306b\u300c\u30ca\u30eb\u6587\u5b57\uff08\\0\uff09\u300d\u3092\u4f7f\u3044\u307e\u3059\u3002\u3061\u306a\u307f\u306b\u3001\u30b3\u30f3\u30d1\u30a4\u30e9\u304c\u81ea\u52d5\u3067\u5165\u308c\u3066\u304f\u308c\u307e\u3059\u3002 \u30ca\u30eb\u6587\u5b57\u306f\u8981\u306f\u300c\u5024\u304c\u30bc\u30ed\u3067\u3042\u308bint\u578b\u300d\u3068\u540c\u3058\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\uff08\\ [&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\/6750"}],"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=6750"}],"version-history":[{"count":9,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/6750\/revisions"}],"predecessor-version":[{"id":19517,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/6750\/revisions\/19517"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6750"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}