{"id":4045,"date":"2021-06-29T17:37:53","date_gmt":"2021-06-29T09:37:53","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=4045"},"modified":"2021-06-29T17:41:28","modified_gmt":"2021-06-29T09:41:28","slug":"c%e4%bd%8d%e5%9f%9f","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=4045","title":{"rendered":"[c]\u4f4d\u57df\/\u4f4d\u6bb5"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n\nstruct Fruit\n{\n    char field1 : 1;\n    char field2 : 1;\n};\n\nint main()\n{\n    Fruit fruit;\n    fruit.field2 = 1; \/\/ \u53ea\u80fd\u4f7f\u75280\u548c1\n    fruit.field1 = 1; \/\/ \u53ea\u80fd\u4f7f\u75280\u548c1\uff0c\u5982\u679c\u5bbd\u5ea62\u5219\u53ef\u4ee50,1,2,3\n    unsigned char uc1= *(unsigned char*)(&amp;fruit);\n    printf(\"a1=%d, a2=%d, c=%d\\n\", fruit.field1, fruit.field2, uc1); \/\/ print: 1, 1, 3\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>1\u3001\u4e00\u4e2a\u4f4d\u57df\u5b58\u50a8\u5728\u540c\u4e00\u4e2a\u5b57\u8282\u4e2d\uff0c\u5982\u4e00\u4e2a\u5b57\u8282\u6240\u5269\u7a7a\u95f4\u4e0d\u591f\u5b58\u653e\u53e6\u4e00\u4f4d\u57df\u65f6\uff0c\u5219\u4f1a\u4ece\u4e0b\u4e00\u5355\u5143\u8d77\u5b58\u653e\u8be5\u4f4d\u57df\n2\u3001\u4f4d\u57df\u7684\u5bbd\u5ea6\u4e0d\u80fd\u8d85\u8fc7\u5b83\u6240\u4f9d\u9644\u7684\u6570\u636e\u7c7b\u578b\u7684\u957f\u5ea6\uff0c\u6210\u5458\u53d8\u91cf\u90fd\u662f\u6709\u7c7b\u578b\u7684\uff0c\u8fd9\u4e2a\u7c7b\u578b\u9650\u5236\u4e86\u6210\u5458\u53d8\u91cf\u7684\u6700\u5927\u957f\u5ea6\uff0c: \u540e\u9762\u7684\u6570\u5b57\u4e0d\u80fd\u8d85\u8fc7\u8fd9\u4e2a\u957f\u5ea6\n3\u3001\u4f4d\u57df\u53ef\u4ee5\u662f\u65e0\u540d\u4f4d\u57df\uff0c\u8fd9\u65f6\u5b83\u53ea\u7528\u6765\u4f5c\u586b\u5145\u6216\u8c03\u6574\u4f4d\u7f6e<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/4045"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4045"}],"version-history":[{"count":2,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/4045\/revisions"}],"predecessor-version":[{"id":4047,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/4045\/revisions\/4047"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}