{"id":11,"date":"2024-07-01T17:39:13","date_gmt":"2024-07-01T09:39:13","guid":{"rendered":"https:\/\/www.buguiling.com\/?p=11"},"modified":"2024-07-01T17:39:13","modified_gmt":"2024-07-01T09:39:13","slug":"%e4%bd%8d%e5%9f%9f","status":"publish","type":"post","link":"https:\/\/www.buguiling.com\/index.php\/2024\/07\/01\/%e4%bd%8d%e5%9f%9f\/","title":{"rendered":"\u4f4d\u57df"},"content":{"rendered":"\n<p>\u6709\u4e9b\u4fe1\u606f\u5728\u5b58\u50a8\u65f6\uff0c\u5e76\u4e0d\u9700\u8981\u5360\u7528\u4e00\u4e2a\u5b8c\u6574\u7684\u5b57\u8282\uff0c \u800c\u53ea\u9700\u5360\u51e0\u4e2a\u6216\u4e00\u4e2a\u4e8c\u8fdb\u5236\u4f4d\u3002\u4f8b\u5982\u5728\u5b58\u653e\u4e00\u4e2a\u5f00\u5173\u91cf\u65f6\uff0c\u53ea\u67090\u548c1 \u4e24\u79cd\u72b6\u6001\uff0c \u7528\u4e00\u4f4d\u4e8c\u8fdb\u4f4d\u5373\u53ef\u3002\u4e3a\u4e86\u8282\u7701\u5b58\u50a8\u7a7a\u95f4\uff0c\u5e76\u4f7f\u5904\u7406\u7b80\u4fbf\uff0c\uff23\u8bed\u8a00\u53c8\u63d0\u4f9b\u4e86\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u79f0\u4e3a\u201c\u4f4d\u57df\u201d\u6216\u201c\u4f4d\u6bb5\u201d\u3002\u6240\u8c13\u201c\u4f4d\u57df\u201d\u662f\u628a\u4e00\u4e2a\u5b57\u8282\u4e2d\u7684\u4e8c\u8fdb\u4f4d\u5212\u5206\u4e3a\u51e0\u4e2a\u4e0d\u540c\u7684\u533a\u57df\uff0c \u5e76\u8bf4\u660e\u6bcf\u4e2a\u533a\u57df\u7684\u4f4d\u6570\u3002\u6bcf\u4e2a\u57df\u6709\u4e00\u4e2a\u57df\u540d\uff0c\u5141\u8bb8\u5728\u7a0b\u5e8f\u4e2d\u6309\u57df\u540d\u8fdb\u884c\u64cd\u4f5c\u3002 \u8fd9\u6837\u5c31\u53ef\u4ee5\u628a\u51e0\u4e2a\u4e0d\u540c\u7684\u5bf9\u8c61\u7528\u4e00\u4e2a\u5b57\u8282\u7684\u4e8c\u8fdb\u5236\u4f4d\u57df\u6765\u8868\u793a\u3002\u4e00\u3001\u4f4d\u57df\u7684\u5b9a\u4e49\u548c\u4f4d\u57df\u53d8\u91cf\u7684\u8bf4\u660e\u4f4d\u57df\u5b9a\u4e49\u4e0e\u7ed3\u6784\u5b9a\u4e49\u76f8\u4eff\uff0c\u5176\u5f62\u5f0f\u4e3a\uff1a<br>struct \u4f4d\u57df\u7ed3\u6784\u540d<br>{ \u4f4d\u57df\u5217\u8868 };<br>\u5176\u4e2d\u4f4d\u57df\u5217\u8868\u7684\u5f62\u5f0f\u4e3a\uff1a \u7c7b\u578b\u8bf4\u660e\u7b26 \u4f4d\u57df\u540d\uff1a\u4f4d\u57df\u957f\u5ea6<br>\u4f8b\u5982\uff1a<br><code>struct bs<br>{<br>    int a:8;<br>    int b:2;<br>    int c:6;<br>};<\/code><br>\u4f4d\u57df\u53d8\u91cf\u7684\u8bf4\u660e\u4e0e\u7ed3\u6784\u53d8\u91cf\u8bf4\u660e\u7684\u65b9\u5f0f\u76f8\u540c\u3002 \u53ef\u91c7\u7528\u5148\u5b9a\u4e49\u540e\u8bf4\u660e\uff0c\u540c\u65f6\u5b9a\u4e49\u8bf4\u660e\u6216\u8005\u76f4\u63a5\u8bf4\u660e\u8fd9\u4e09\u79cd\u65b9\u5f0f\u3002\u4f8b\u5982\uff1a<br>struct bs<br>{<br>int a:8;<br>int b:2;<br>int c:6;<br>}data;<br>\u8bf4\u660edata\u4e3abs\u53d8\u91cf\uff0c\u5171\u5360\u4e24\u4e2a\u5b57\u8282\u3002\u5176\u4e2d\u4f4d\u57dfa\u53608\u4f4d\uff0c\u4f4d\u57dfb\u53602\u4f4d\uff0c\u4f4d\u57dfc\u53606\u4f4d\u3002\u5bf9\u4e8e\u4f4d\u57df\u7684\u5b9a\u4e49\u5c1a\u6709\u4ee5\u4e0b\u51e0\u70b9\u8bf4\u660e\uff1a<br><br>1. \u4e00\u4e2a\u4f4d\u57df\u5fc5\u987b\u5b58\u50a8\u5728\u540c\u4e00\u4e2a\u5b57\u8282\u4e2d\uff0c\u4e0d\u80fd\u8de8\u4e24\u4e2a\u5b57\u8282\u3002\u5982\u4e00\u4e2a\u5b57\u8282\u6240\u5269\u7a7a\u95f4\u4e0d\u591f\u5b58\u653e\u53e6\u4e00\u4f4d\u57df\u65f6\uff0c\u5e94\u4ece\u4e0b\u4e00\u5355\u5143\u8d77\u5b58\u653e\u8be5\u4f4d\u57df\u3002\u4e5f\u53ef\u4ee5\u6709\u610f\u4f7f\u67d0\u4f4d\u57df\u4ece\u4e0b\u4e00\u5355\u5143\u5f00\u59cb\u3002\u4f8b\u5982\uff1a<br>struct bs<br>{<br>unsigned a:4<br>unsigned :0 \/*\u7a7a\u57df*\/<br>unsigned b:4 \/*\u4ece\u4e0b\u4e00\u5355\u5143\u5f00\u59cb\u5b58\u653e*\/<br>unsigned c:4<br>}<br>\u5728\u8fd9\u4e2a\u4f4d\u57df\u5b9a\u4e49\u4e2d\uff0ca\u5360\u7b2c\u4e00\u5b57\u8282\u76844\u4f4d\uff0c\u540e4\u4f4d\u586b0\u8868\u793a\u4e0d\u4f7f\u7528\uff0cb\u4ece\u7b2c\u4e8c\u5b57\u8282\u5f00\u59cb\uff0c\u5360\u75284\u4f4d\uff0cc\u5360\u75284\u4f4d\u3002<br><br>2. \u7531\u4e8e\u4f4d\u57df\u4e0d\u5141\u8bb8\u8de8\u4e24\u4e2a\u5b57\u8282\uff0c\u56e0\u6b64\u4f4d\u57df\u7684\u957f\u5ea6\u4e0d\u80fd\u5927\u4e8e\u4e00\u4e2a\u5b57\u8282\u7684\u957f\u5ea6\uff0c\u4e5f\u5c31\u662f\u8bf4\u4e0d\u80fd\u8d85\u8fc78\u4f4d\u4e8c\u8fdb\u4f4d\u3002<br><br>3. \u4f4d\u57df\u53ef\u4ee5\u65e0\u4f4d\u57df\u540d\uff0c\u8fd9\u65f6\u5b83\u53ea\u7528\u6765\u4f5c\u586b\u5145\u6216\u8c03\u6574\u4f4d\u7f6e\u3002\u65e0\u540d\u7684\u4f4d\u57df\u662f\u4e0d\u80fd\u4f7f\u7528\u7684\u3002\u4f8b\u5982\uff1a<br>struct k<br>{<br>int a:1<br>int :2 \/*\u8be52\u4f4d\u4e0d\u80fd\u4f7f\u7528*\/<br>int b:3<br>int c:2<br>};<br>\u4ece\u4ee5\u4e0a\u5206\u6790\u53ef\u4ee5\u770b\u51fa\uff0c\u4f4d\u57df\u5728\u672c\u8d28\u4e0a\u5c31\u662f\u4e00\u79cd\u7ed3\u6784\u7c7b\u578b\uff0c \u4e0d\u8fc7\u5176\u6210\u5458\u662f\u6309\u4e8c\u8fdb\u4f4d\u5206\u914d\u7684\u3002<br><br>\u4e8c\u3001\u4f4d\u57df\u7684\u4f7f\u7528<\/p>\n\n\n\n<p>\u4f4d\u57df\u7684\u4f7f\u7528\u548c\u7ed3\u6784\u6210\u5458\u7684\u4f7f\u7528\u76f8\u540c\uff0c\u5176\u4e00\u822c\u5f62\u5f0f\u4e3a\uff1a \u4f4d\u57df\u53d8\u91cf\u540d\u00b7\u4f4d\u57df\u540d \u4f4d\u57df\u5141\u8bb8\u7528\u5404\u79cd\u683c\u5f0f\u8f93\u51fa\u3002<\/p>\n\n\n\n<p><br>main(){<br>struct bs<br>{<br>unsigned a:1;<br>unsigned b:3;<br>unsigned c:4;<br>} bit,*pbit;<br>bit.a=1;<br>bit.b=7;<br>bit.c=15;<br>printf(&#8220;%d,%d,%d\/n&#8221;,bit.a,bit.b,bit.c);<br>pbit=&amp;bit;<br>pbit-&gt;a=0;<br>pbit-&gt;b&amp;=3;<br>pbit-&gt;c|=1;<br>printf(&#8220;%d,%d,%d\/n&#8221;,pbit-&gt;a,pbit-&gt;b,pbit-&gt;c);<br>}<br>\u4e0a\u4f8b\u7a0b\u5e8f\u4e2d\u5b9a\u4e49\u4e86\u4f4d\u57df\u7ed3\u6784bs\uff0c\u4e09\u4e2a\u4f4d\u57df\u4e3aa,b,c\u3002\u8bf4\u660e\u4e86bs\u7c7b\u578b\u7684\u53d8\u91cfbit\u548c\u6307\u5411bs\u7c7b\u578b\u7684\u6307\u9488\u53d8\u91cfpbit\u3002\u8fd9\u8868\u793a\u4f4d\u57df\u4e5f\u662f\u53ef\u4ee5\u4f7f\u7528\u6307\u9488\u7684\u3002<br>\u7a0b\u5e8f\u76849\u300110\u300111\u4e09\u884c\u5206\u522b\u7ed9\u4e09\u4e2a\u4f4d\u57df\u8d4b\u503c\u3002( \u5e94\u6ce8\u610f\u8d4b\u503c\u4e0d\u80fd\u8d85\u8fc7\u8be5\u4f4d\u57df\u7684\u5141\u8bb8\u8303\u56f4)\u7a0b\u5e8f\u7b2c12\u884c\u4ee5\u6574\u578b\u91cf\u683c\u5f0f\u8f93\u51fa\u4e09\u4e2a\u57df\u7684\u5185\u5bb9\u3002\u7b2c13\u884c\u628a\u4f4d\u57df\u53d8\u91cfbit\u7684\u5730\u5740\u9001\u7ed9\u6307\u9488\u53d8\u91cfpbit\u3002\u7b2c14\u884c\u7528\u6307\u9488\u65b9\u5f0f\u7ed9\u4f4d\u57dfa\u91cd\u65b0\u8d4b\u503c\uff0c\u8d4b\u4e3a0\u3002\u7b2c15\u884c\u4f7f\u7528\u4e86\u590d\u5408\u7684\u4f4d\u8fd0\u7b97\u7b26&#8221;&amp;=&#8221;\uff0c \u8be5\u884c\u76f8\u5f53\u4e8e\uff1a pbit-&gt;b=pbit-&gt;b&amp;3\u4f4d\u57dfb\u4e2d\u539f\u6709\u503c\u4e3a7\uff0c\u4e0e3\u4f5c\u6309\u4f4d\u4e0e\u8fd0\u7b97\u7684\u7ed3\u679c\u4e3a3(111&amp;011=011,\u5341\u8fdb\u5236\u503c\u4e3a3)\u3002\u540c\u6837\uff0c\u7a0b\u5e8f\u7b2c16\u884c\u4e2d\u4f7f\u7528\u4e86\u590d\u5408\u4f4d\u8fd0\u7b97&#8221;|=&#8221;\uff0c \u76f8\u5f53\u4e8e\uff1a pbit-&gt;c=pbit-&gt;c|1\u5176\u7ed3\u679c\u4e3a15\u3002\u7a0b\u5e8f\u7b2c17\u884c\u7528\u6307\u9488\u65b9\u5f0f\u8f93\u51fa\u4e86\u8fd9\u4e09\u4e2a\u57df\u7684\u503c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u4e9b\u4fe1\u606f\u5728\u5b58\u50a8\u65f6\uff0c\u5e76\u4e0d\u9700\u8981\u5360\u7528\u4e00\u4e2a\u5b8c\u6574\u7684\u5b57\u8282\uff0c \u800c\u53ea\u9700\u5360\u51e0\u4e2a\u6216\u4e00\u4e2a\u4e8c\u8fdb\u5236\u4f4d\u3002\u4f8b\u5982\u5728\u5b58\u653e\u4e00\u4e2a\u5f00\u5173\u91cf\u65f6\uff0c\u53ea\u67090\u548c1 &hellip; <a href=\"https:\/\/www.buguiling.com\/index.php\/2024\/07\/01\/%e4%bd%8d%e5%9f%9f\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u4f4d\u57df\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.buguiling.com\/index.php\/wp-json\/wp\/v2\/posts\/11"}],"collection":[{"href":"https:\/\/www.buguiling.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.buguiling.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.buguiling.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.buguiling.com\/index.php\/wp-json\/wp\/v2\/comments?post=11"}],"version-history":[{"count":2,"href":"https:\/\/www.buguiling.com\/index.php\/wp-json\/wp\/v2\/posts\/11\/revisions"}],"predecessor-version":[{"id":13,"href":"https:\/\/www.buguiling.com\/index.php\/wp-json\/wp\/v2\/posts\/11\/revisions\/13"}],"wp:attachment":[{"href":"https:\/\/www.buguiling.com\/index.php\/wp-json\/wp\/v2\/media?parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.buguiling.com\/index.php\/wp-json\/wp\/v2\/categories?post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.buguiling.com\/index.php\/wp-json\/wp\/v2\/tags?post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}