{"id":315671,"date":"2024-05-21T00:06:35","date_gmt":"2024-05-20T16:06:35","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/315671.html"},"modified":"2024-05-21T00:06:45","modified_gmt":"2024-05-20T16:06:45","slug":"c-%e8%af%ad%e8%a8%80%e4%b8%ad%e6%95%b0%e7%bb%84%e5%85%83%e7%b4%a0%e4%b8%8b%e6%a0%87%e7%9a%84%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b%e6%9c%89%e5%93%aa%e4%ba%9b","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/315671.html","title":{"rendered":"c \u8bed\u8a00\u4e2d\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\u7684\u6570\u636e\u7c7b\u578b\u6709\u54ea\u4e9b"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27035600\/71fb0cae-e5c0-467a-9eea-20941da87ca9.webp\" alt=\"c \u8bed\u8a00\u4e2d\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\u7684\u6570\u636e\u7c7b\u578b\u6709\u54ea\u4e9b\" \/><\/p>\n<p><p>\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\u5728C\u8bed\u8a00\u4e2d\u57fa\u672c\u4e0a\u53ef\u4ee5\u662f\u4efb\u4f55\u6574\u6570\u7c7b\u578b\uff0c\u5305\u62ec<code>int<\/code>\u3001<code>unsigned int<\/code>\u3001<code>short<\/code>\u3001<code>unsigned short<\/code>\u3001<code>long<\/code>\u3001<code>unsigned long<\/code>\u7b49\u3002<strong>C\u8bed\u8a00\u6807\u51c6\u89c4\u5b9a\u6570\u7ec4\u4e0b\u6807\u5fc5\u987b\u662f\u6574\u578b\u8868\u8fbe\u5f0f<\/strong>\uff0c\u8fd9\u662f\u56e0\u4e3a\u5728\u8ba1\u7b97\u673a\u5185\u5b58\u4e2d\uff0c\u6570\u7ec4\u662f\u901a\u8fc7\u8ba1\u7b97\u504f\u79fb\u91cf\u6765\u8bbf\u95ee\u5177\u4f53\u5143\u7d20\u7684\uff0c\u800c\u8fd9\u4e2a\u504f\u79fb\u91cf\u8981\u4e0e\u6570\u7ec4\u7684\u6570\u636e\u7c7b\u578b\u5bf9\u9f50\uff0c\u6240\u4ee5\u9700\u8981\u4f7f\u7528\u6574\u6570\u7c7b\u578b\u7684\u4e0b\u6807\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u9ed8\u8ba4\u7684\u4e0b\u6807\u6570\u636e\u7c7b\u578b\u662f<code>int<\/code>\uff0c\u4f46\u662f\u5982\u679c\u8981\u5904\u7406\u975e\u5e38\u5927\u7684\u6570\u7ec4\uff0c\u53ef\u80fd\u4f1a\u4f7f\u7528<code>long<\/code>\u6216<code>unsigned long<\/code>\uff0c\u4ee5\u5141\u8bb8\u66f4\u5927\u8303\u56f4\u7684\u5185\u5b58\u7d22\u5f15\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u5177\u4f53\u6df1\u5165\u5730\u5206\u6790\u6570\u7ec4\u4e0b\u6807\u7684\u4e0d\u540c\u6574\u6570\u6570\u636e\u7c7b\u578b\u4ee5\u53ca\u5b83\u4eec\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u7684\u5dee\u5f02\u548c\u9650\u5236\u3002<\/p>\n<\/p>\n<p><p><strong>\u4e00\u3001INT \u548c UNSIGNED INT<\/strong><\/p>\n<\/p>\n<p><p><strong>C\u8bed\u8a00\u4e2d\uff0c<code>int<\/code>\u7c7b\u578b\u7ecf\u5e38\u7528\u4f5c\u6570\u7ec4\u4e0b\u6807<\/strong>\u3002<code>int<\/code>\u7c7b\u578b\u901a\u5e38\u7528\u4e8e\u9002\u4e2d\u5927\u5c0f\u7684\u6570\u7ec4\uff0c\u56e0\u4e3a\u5b83\u80fd\u591f\u5904\u7406\u5927\u90e8\u5206\u5e38\u89c4\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u6570\u636e\u96c6\u5408\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u9ed8\u8ba4\u7c7b\u578b<\/strong>: \u5728\u4e0d\u6307\u5b9a\u5177\u4f53\u7c7b\u578b\u65f6\uff0c\u5927\u591a\u6570\u7f16\u8bd1\u5668\u5c06\u4e0b\u6807\u89e3\u91ca\u4e3a<code>int<\/code>\u7c7b\u578b\u3002<\/li>\n<li><strong>\u7b26\u53f7\u4e0e\u4e0a\u4e0b\u6587<\/strong>: <code>int<\/code>\u7c7b\u578b\u53ef\u4ee5\u662f\u8d1f\u503c\uff0c\u4f46\u4f5c\u4e3a\u6570\u7ec4\u4e0b\u6807\u65f6\uff0c\u8d1f\u503c\u662f\u6ca1\u6709\u610f\u4e49\u7684\uff0c\u56e0\u4e3a\u6570\u7ec4\u7684\u7d22\u5f15\u4e0d\u80fd\u662f\u8d1f\u6570\u3002<\/li>\n<\/ul>\n<p><p><strong><code>unsigned int<\/code>\u7528\u4e8e\u786e\u4fdd\u4e0b\u6807\u603b\u662f\u975e\u8d1f\u6570<\/strong>\u3002\u8fd9\u6709\u65f6\u5019\u53ef\u4ee5\u907f\u514d\u7531\u4e8e\u8d1f\u7d22\u5f15\u5e26\u6765\u7684\u6f5c\u5728\u9519\u8bef\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u975e\u8d1f\u786e\u4fdd<\/strong>: \u4f7f\u7528<code>unsigned int<\/code>\u786e\u4fdd\u4ee3\u7801\u4e2d\u4e0d\u4f1a\u7531\u4e8e\u610f\u5916\u4f7f\u7528\u4e86\u8d1f\u7d22\u5f15\u800c\u51fa\u73b0\u8fd0\u884c\u65f6\u9519\u8bef\u3002<\/li>\n<li><strong>\u8303\u56f4<\/strong>: \u76f8\u6bd4\u4e8e<code>int<\/code>\uff0c<code>unsigned int<\/code>\u53ef\u4ee5\u8ba9\u6570\u7ec4\u7684\u6709\u6548\u7d22\u5f15\u8303\u56f4\u7ffb\u500d\u3002<\/li>\n<\/ul>\n<p><p><strong>\u4e8c\u3001SHORT \u548c UNSIGNED SHORT<\/strong><\/p>\n<\/p>\n<p><p><strong>\u8f83\u5c0f\u7684\u6570\u7ec4\u6216\u5728\u5185\u5b58\u8f83\u53d7\u9650\u7684\u5d4c\u5165\u5f0f\u7cfb\u7edf\u4e2d\uff0c\u53ef\u80fd\u4f1a\u4f7f\u7528<code>short<\/code>\u6216<code>unsigned short<\/code>\u4f5c\u4e3a\u6570\u7ec4\u4e0b\u6807\u3002<\/strong><\/p>\n<\/p>\n<ul>\n<li><strong>\u5185\u5b58\u4f18\u5316<\/strong>: \u5bf9\u4e8e\u53ea\u9700\u8981\u5c11\u91cf\u5143\u7d20\u7684\u6570\u7ec4\uff0c\u4f7f\u7528<code>short<\/code>\u7c7b\u578b\u53ef\u4ee5\u8282\u7701\u5185\u5b58\uff0c\u56e0\u4e3a<code>short<\/code>\u901a\u5e38\u53ea\u67092\u5b57\u8282\u5927\u5c0f\u3002<\/li>\n<li><strong>\u8303\u56f4\u9650\u5236<\/strong>: \u4f7f\u7528<code>short<\/code>\u7c7b\u578b\u7684\u6570\u7ec4\u4e0b\u6807\uff0c\u53ef\u4ee5\u5904\u7406\u7684\u5143\u7d20\u6570\u91cf\u5c11\u4e8e<code>int<\/code>\u7c7b\u578b\uff0c\u8fd9\u53ef\u80fd\u4f1a\u9650\u5236\u6570\u7ec4\u7684\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<p><p><strong>\u4e09\u3001LONG \u548c UNSIGNED LONG<\/strong><\/p>\n<\/p>\n<p><p><strong>\u5bf9\u4e8e\u975e\u5e38\u5927\u7684\u6570\u7ec4\uff0c\u53ef\u80fd\u4f1a\u9700\u8981\u4f7f\u7528<code>long<\/code>\u6216<code>unsigned long<\/code>\u4f5c\u4e3a\u5143\u7d20\u4e0b\u6807\u3002<\/strong><\/p>\n<\/p>\n<ul>\n<li><strong>\u5927\u6570\u7ec4\u652f\u6301<\/strong>: \u5f53\u6570\u7ec4\u5927\u5c0f\u8d85\u8fc7<code>int<\/code>\u80fd\u8868\u8fbe\u7684\u8303\u56f4\u65f6\uff0c<code>long<\/code>\u6216<code>unsigned long<\/code>\u53ef\u4ee5\u652f\u6301\u8bbf\u95ee\u8fd9\u6837\u5927\u7684\u6570\u7ec4\u3002<\/li>\n<li><strong>\u7cfb\u7edf\u4f9d\u8d56<\/strong>: <code>long<\/code>\u7c7b\u578b\u7684\u5927\u5c0f\u53d6\u51b3\u4e8e\u4e0d\u540c\u7684\u7f16\u8bd1\u5668\u548c\u64cd\u4f5c\u7cfb\u7edf\uff0c\u901a\u5e38\u572832\u4f4d\u7cfb\u7edf\u4e0a\u662f4\u5b57\u8282\uff0c\u572864\u4f4d\u7cfb\u7edf\u4e0a\u662f8\u5b57\u8282\u3002<\/li>\n<\/ul>\n<p><p><strong>\u56db\u3001SIZE_T<\/strong><\/p>\n<\/p>\n<p><p>\u5c3d\u7ba1\u4e0d\u662f\u4f20\u7edf\u610f\u4e49\u4e0a\u7684\u6574\u6570\u7c7b\u578b\u58f0\u660e\uff0c<code>size_t<\/code>\u662fC\u8bed\u8a00\u4e2d\u7684\u4e00\u79cd\u7279\u6b8a\u7c7b\u578b\uff0c\u7ecf\u5e38\u88ab\u7528\u4e8e\u8868\u793a\u5bf9\u8c61\u7684\u5927\u5c0f\u6216\u8005\u6570\u7ec4\u7684\u7d22\u5f15\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u8de8\u5e73\u53f0\u4e00\u81f4\u6027<\/strong>: <code>size_t<\/code>\u7c7b\u578b\u7684\u5927\u5c0f\u662f\u6839\u636e\u5e73\u53f0\u8fdb\u884c\u5b9a\u4e49\u7684\uff0c\u80fd\u591f\u4fdd\u8bc1\u5728\u8be5\u5e73\u53f0\u4e0a\u53ef\u4ee5\u8bbf\u95ee\u6570\u7ec4\u7684\u4efb\u610f\u5143\u7d20\u800c\u4e0d\u4f1a\u6ea2\u51fa\u3002<\/li>\n<li><strong>\u6807\u51c6\u5e93\u517c\u5bb9\u6027<\/strong>: \u5728C\u6807\u51c6\u5e93\u4e2d\u5f88\u591a\u51fd\u6570\uff0c\u4f8b\u5982<code>malloc<\/code>\u548c<code>sizeof<\/code>\u90fd\u4f7f\u7528<code>size_t<\/code>\u7c7b\u578b\uff0c\u8fd9\u4f7f\u5f97<code>size_t<\/code>\u6210\u4e3a\u5904\u7406\u6570\u7ec4\u548c\u5185\u5b58\u5206\u914d\u7684\u9996\u9009\u7c7b\u578b\u3002<\/li>\n<\/ul>\n<p><p>\u7efc\u4e0a\u6240\u8ff0\uff0cC\u8bed\u8a00\u5141\u8bb8\u4f7f\u7528\u591a\u79cd\u6574\u6570\u7c7b\u578b\u4f5c\u4e3a\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\uff0c\u6bcf\u79cd\u7c7b\u578b\u90fd\u6709\u5176\u9002\u7528\u60c5\u51b5\u548c\u9650\u5236\u3002\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u5f00\u53d1\u8005\u9700\u8981\u6839\u636e\u6570\u7ec4\u7684\u5927\u5c0f\u548c\u5bf9\u6027\u80fd\u7684\u8981\u6c42\u6765\u9009\u62e9\u6700\u5408\u9002\u7684\u7c7b\u578b\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u9ed8\u8ba4\u7684<code>int<\/code>\u7c7b\u578b\u5c31\u8db3\u591f\u5e94\u5bf9\u5927\u591a\u6570\u60c5\u51b5\uff0c\u4f46\u5728\u7279\u5b9a\u573a\u666f\u4e0b\u9009\u62e9\u5408\u9002\u7684\u4e0b\u6807\u7c7b\u578b\u53ef\u4ee5\u63d0\u9ad8\u6027\u80fd\u6216\u8005\u907f\u514d\u6f5c\u5728\u9519\u8bef\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u4ec0\u4e48\u662f\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\u7684\u6570\u636e\u7c7b\u578b\uff1f<\/strong><\/p>\n<p>\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\u7684\u6570\u636e\u7c7b\u578b\u662f\u7528\u6765\u6807\u8bc6\u6570\u7ec4\u4e2d\u6bcf\u4e2a\u5143\u7d20\u4f4d\u7f6e\u7684\u4e00\u79cd\u6570\u636e\u7c7b\u578b\u3002\u5728C\u8bed\u8a00\u4e2d\uff0c\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\u7684\u6570\u636e\u7c7b\u578b\u53ef\u4ee5\u662f\u6574\u6570\u7c7b\u578b\uff0c\u5305\u62ec\u6709\u7b26\u53f7\u6574\u6570\u548c\u65e0\u7b26\u53f7\u6574\u6570\u3002<\/p>\n<p><strong>2. \u54ea\u4e9b\u6570\u636e\u7c7b\u578b\u53ef\u4ee5\u4f5c\u4e3a\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\uff1f<\/strong><\/p>\n<p>C\u8bed\u8a00\u4e2d\u5e38\u7528\u7684\u6574\u6570\u6570\u636e\u7c7b\u578b\uff0c\u5982int\u3001short\u3001long\u7b49\u53ef\u4ee5\u4f5c\u4e3a\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\u3002\u6b64\u5916\uff0c\u65e0\u7b26\u53f7\u6574\u6570\u6570\u636e\u7c7b\u578b\uff08\u5982unsigned int\uff09\u4e5f\u53ef\u4ee5\u4f5c\u4e3a\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5b57\u7b26\u7c7b\u578b\uff08\u5982char\uff09\u867d\u7136\u662f\u6574\u6570\u7c7b\u578b\uff0c\u4f46\u7531\u4e8e\u5176\u53d6\u503c\u8303\u56f4\u8f83\u5c0f\uff08\u901a\u5e38\u4e3a-128\u5230127\u62160\u5230255\uff09\uff0c\u5f53\u4f5c\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\u65f6\u9700\u8981\u8c28\u614e\u4f7f\u7528\u3002<\/p>\n<p><strong>3. \u6570\u7ec4\u5143\u7d20\u4e0b\u6807\u7684\u6570\u636e\u7c7b\u578b\u9009\u62e9\u6709\u4ec0\u4e48\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9\uff1f<\/strong><\/p>\n<p>\u5728\u9009\u62e9\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\u7684\u6570\u636e\u7c7b\u578b\u65f6\uff0c\u9700\u8981\u8003\u8651\u6570\u7ec4\u7684\u5927\u5c0f\u548c\u53ef\u80fd\u53d6\u503c\u8303\u56f4\u3002\u5982\u679c\u6570\u7ec4\u8f83\u5c0f\u4e14\u4e0b\u6807\u503c\u8f83\u5c0f\uff0c\u53ef\u4ee5\u9009\u62e9\u8f83\u5c0f\u7684\u6574\u6570\u7c7b\u578b\uff0c\u4ee5\u8282\u7701\u5185\u5b58\u7a7a\u95f4\u3002\u800c\u5982\u679c\u6570\u7ec4\u8f83\u5927\u4e14\u4e0b\u6807\u503c\u8f83\u5927\uff0c\u53ef\u4ee5\u9009\u62e9\u8f83\u5927\u7684\u6574\u6570\u7c7b\u578b\uff0c\u4ee5\u907f\u514d\u4e0b\u6807\u6ea2\u51fa\u3002\u540c\u65f6\uff0c\u8fd8\u8981\u6ce8\u610f\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\u7c7b\u578b\u4e0e\u5faa\u73af\u53d8\u91cf\u7c7b\u578b\u7684\u5339\u914d\uff0c\u4ee5\u786e\u4fdd\u5faa\u73af\u80fd\u591f\u6b63\u786e\u904d\u5386\u6570\u7ec4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u6570\u7ec4\u5143\u7d20\u4e0b\u6807\u5728C\u8bed\u8a00\u4e2d\u57fa\u672c\u4e0a\u53ef\u4ee5\u662f\u4efb\u4f55\u6574\u6570\u7c7b\u578b\uff0c\u5305\u62ecint\u3001unsigned int\u3001short\u3001unsign [&hellip;]","protected":false},"author":3,"featured_media":315677,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/315671"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=315671"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/315671\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/315677"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=315671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=315671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=315671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}