{"id":49,"date":"2026-03-12T23:21:10","date_gmt":"2026-03-12T15:21:10","guid":{"rendered":"https:\/\/www.caldm.cn\/?p=49"},"modified":"2026-03-13T20:15:53","modified_gmt":"2026-03-13T12:15:53","slug":"c3-%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%92%8c%e6%a0%bc%e5%bc%8f%e5%8c%96%e8%be%93%e5%85%a5%e8%be%93%e5%87%ba","status":"publish","type":"post","link":"https:\/\/www.caldm.cn\/index.php\/2026\/03\/12\/c3-%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%92%8c%e6%a0%bc%e5%bc%8f%e5%8c%96%e8%be%93%e5%85%a5%e8%be%93%e5%87%ba\/","title":{"rendered":"C3 \u5b57\u7b26\u4e32\u548c\u683c\u5f0f\u5316\u8f93\u5165\u8f93\u51fa"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1. \u5b57\u7b26\u4e32<\/h2>\n\n\n\n<p>\u5b57\u7b26\u4e32\u662f\u4e00\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u7684\u5e8f\u5217\u3002\u53cc\u5f15\u53f7\u4e0d\u662f\u5b57\u7b26\u4e32\u7684\u4e00\u90e8\u5206\uff0c\u5b83\u7684\u4f5c\u7528\u4ec5\u662f\u544a\u8bc9\u7f16\u8bd1\u5668\u5b83\u62ec\u8d77\u6765\u7684\u5185\u5bb9\u662f\u5b57\u7b26\u4e32\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1.1 <code>char<\/code>\u7c7b\u578b\u6570\u7ec4\u548c<code>null<\/code>\u5b57\u7b26<\/h3>\n\n\n\n<p>\u5b57\u7b26\u4e32\u672b\u5c3e\u7684<code>\\0<\/code>\u662f\u7a7a\u5b57\u7b26\uff0cC\u8bed\u8a00\u7528\u5b83\u6807\u8bb0\u5b57\u7b26\u4e32\u7684\u7ed3\u675f\uff0c\u5176ASCII\u7801\u503c\u662f0\u3002C\u8bed\u8a00\u4e2d\u5b57\u7b26\u4e32\u4e00\u5b9a\u4ee5\u7a7a\u5b57\u7b26\u7ed3\u5c3e\uff0c\u56e0\u6b64<code>char<\/code>\u6570\u7ec4\u4e00\u5b9a\u8981\u6bd4\u5e26\u5b58\u50a8\u5b57\u7b26\u4e32\u7684\u5b57\u7b26\u6570\u591a1\u3002<\/p>\n\n\n\n<p>\u6570\u7ec4\u662f\u540c\u7c7b\u578b\u6570\u636e\u5143\u7d20\u7684\u6709\u5e8f\u5e8f\u5217\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1.2 \u4f7f\u7528\u5b57\u7b26\u4e32<\/h3>\n\n\n\n<p><code>sizeof<\/code>\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u7ed9\u51fa\u5bf9\u8c61\u7684\u5927\u5c0f\uff0c<code>strlen<\/code>\u7ed9\u51fa\u5b57\u7b26\u4e32\u4e2d\u7684\u5b57\u7b26\u957f\u5ea6\u3002\u867d\u71361\u5b57\u8282\u5b58\u50a81\u5b57\u7b26\uff0c\u4f46\u662f\u5e76\u4e0d\u80fd\u5c06\u4e24\u8005\u6df7\u7528\u3002<\/p>\n\n\n\n<p>\u5047\u8bbe<code>char[40] name<\/code>\u5b58\u50a8\u5b57\u7b26\u4e32\u201cCaldm\u201d\uff0c<code>sizeof<\/code>\u8fd4\u56de\u7684\u503c\u662f40\uff0c\u800c<code>strlen<\/code>\u8fd4\u56de\u7684\u503c\u662f5\u3002\u5373\u4f7f\u76f4\u63a5\u4f20\u9012\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\uff0c<code>sizeof<\/code>\u7684\u7ed3\u679c\u4e5f\u4f1a\u6bd4<code>strlen<\/code>\u7684\u503c\u5927\uff0c\u56e0\u4e3a<code>sizeof<\/code>\u628a\u5b57\u7b26\u4e32\u672b\u5c3e\u4e0d\u53ef\u89c1\u7684\u7a7a\u5b57\u7b26<code>\\0<\/code>\u4e5f\u8ba1\u7b97\u5728\u5185\u4e86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. \u5e38\u91cf\u548cC\u9884\u5904\u7406\u5668<\/h2>\n\n\n\n<p>\u4e3a\u4ec0\u4e48\u7b26\u53f7\u5e38\u91cf\u66f4\u597d\uff1f<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5e38\u91cf\u540d\u6bd4\u6570\u5b57\u8868\u8fbe\u7684\u4fe1\u606f\u66f4\u591a<\/li>\n\n\n\n<li>\u5f53\u7a0b\u5e8f\u4e2d\u591a\u5904\u4f7f\u7528\u5e38\u91cf\uff0c\u4e14\u9700\u8981\u66f4\u6539\u5e38\u91cf\u65f6\uff0c\u4f7f\u7528\u7b26\u53f7\u5e38\u91cf\u53ea\u9700\u8981\u4fee\u6539\u7b26\u53f7\u5e38\u91cf\u7684\u5b9a\u4e49\uff0c\u4e0d\u7528\u518d\u7a0b\u5e8f\u4e2d\u9010\u4e00\u4fee\u6539<\/li>\n<\/ul>\n\n\n\n<p>\u5982\u4f55\u521b\u5efa\u7b26\u53f7\u5e38\u91cf\uff1f<\/p>\n\n\n\n<p>\u65b9\u6cd5\u4e00\uff1a\u58f0\u660e\u4e00\u4e2a\u53d8\u91cf\uff0c\u7136\u540e\u5c06\u53d8\u91cf\u4fee\u6539\u4e3a\u6240\u9700\u7684\u5e38\u91cf\u3002<br>\u8fd9\u6837\u505a\u4f9d\u7136\u53ef\u80fd\u5728\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u4fee\u6539\u5b83\u7684\u503c\uff0c\u66f4\u597d\u7684\u505a\u6cd5\u662f\u4f7f\u7528<strong>C\u9884\u5904\u7406\u5668<\/strong><\/p>\n\n\n\n<p>\u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528C\u9884\u5904\u7406\u5668 <code>#define \u5e38\u91cf\u540d \u5e38\u91cf\u503c<\/code><\/p>\n\n\n\n<p>\u547d\u540d\u89c4\u5219\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5e38\u91cf\u540d\u5e94\u5f53\u91c7\u7528\u5168\u5927\u5199\u5b57\u6bcd+\u4e0b\u5212\u7ebf\u8fde\u63a5<\/li>\n\n\n\n<li>\u4e5f\u53ef\u5728\u540d\u79f0\u524d\u5e26<code>c_<\/code>\u6216<code>k_<\/code>\u524d\u7f00\u6765\u8868\u793a\u5e38\u91cf\uff08\u6bd4\u8f83\u5c11\u89c1\uff09<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2.1 <code>const<\/code>\u9650\u5b9a\u7b26<\/h3>\n\n\n\n<p><code>const<\/code>\u5173\u952e\u5b57\uff08C90\u65b0\u589e\uff09\u7528\u4e8e\u9650\u5b9a\u4e00\u4e2a\u53d8\u91cf\u4e3a\u53ea\u8bfb\uff08\u5728C\u8bed\u8a00\u4e2d\uff0c\u4f7f\u7528const\u7c7b\u578b\u9650\u5b9a\u7b26\u58f0\u660e\u7684\u662f\u53d8\u91cf\uff0c\u4e0d\u662f\u5e38\u91cf\uff09\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2.2 \u7b26\u53f7\u5e38\u91cf<\/h3>\n\n\n\n<p>C\u5934\u6587\u4ef6<code>limits.h<\/code>\u548c<code>float.h<\/code>\u5206\u522b\u63d0\u4f9b\u4e86\u6574\u6570\u7c7b\u578b\u548c\u6d6e\u70b9\u6570\u7c7b\u578b\u5927\u5c0f\u9650\u5236\u76f8\u5173\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u6bcf\u4e2a\u5934\u6587\u4ef6\u90fd\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u4f9b\u5b9e\u73b0\u4f7f\u7528\u7684\u7b26\u53f7\u5e38\u91cf\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. <code>printf()<\/code>\u548c<code>scanf()<\/code><\/h2>\n\n\n\n<p><code>printf()<\/code>\u548c<code>scanf()<\/code>\u662f\u8f93\u5165\/\u8f93\u51fa\u51fd\u6570\uff0c\u7b80\u79f0I\/O\u51fd\u6570\u3002C\u6700\u5f00\u59cb\u5427\u8f93\u5165\/\u8f93\u51fa\u7559\u7ed9\u7f16\u8bd1\u5668\u7684\u5b9e\u73b0\u8005\uff0c\u4f46C90\u548cC99\u6807\u51c6\u89c4\u5b9a\u4e86\u8fd9\u4e9b\u51fd\u6570\u7684\u6807\u51c6\u7248\u672c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.1 <code>printf()<\/code>\u51fd\u6570<\/h3>\n\n\n\n<p><code>printf()<\/code>\u51fd\u6570\u6253\u5370\u6570\u636e\u7684\u6307\u4ee4\u8981\u4e0e\u5f85\u6253\u5370\u6570\u636e\u7684\u7c7b\u578b\u76f8\u5339\u914d\uff0c\u4f8b\u5982<code>%d<\/code>\u6253\u5370\u6574\u6570\uff0c<code>%f<\/code>\u6253\u5370\u5355\u7cbe\u5ea6\u6d6e\u70b9\u6570\uff08<code>float<\/code>\uff09\uff0c\u8fd9\u4e9b\u7b26\u53f7\u88ab\u79f0\u4e3a\u8f6c\u6362\u8bf4\u660e\uff08<em>conversion specification<\/em>\uff09\uff0c\u5b83\u4eec\u6307\u5b9a\u4e86\u5982\u4f55\u628a\u6570\u636e\u8f6c\u6362\u6210\u53ef\u663e\u793a\u7684\u5f62\u5f0f\u3002<\/p>\n\n\n\n<p><em><code>printf()<\/code>\u7684\u6807\u8bb0<\/em><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u6807\u8bb0<\/th><th>\u610f\u4e49<\/th><\/tr><\/thead><tbody><tr><td><code>-<\/code><\/td><td>\u5f85\u6253\u5370\u9879\u5de6\u5bf9\u9f50<\/td><\/tr><tr><td><code>+<\/code><\/td><td>\u663e\u793a\u7b26\u53f7\uff0c\u6b63\u6570\u663e\u793a<code>+<\/code>\uff0c\u8d1f\u6570\u663e\u793a<code>-<\/code><\/td><\/tr><tr><td>\u7a7a\u683c<\/td><td>\u524d\u5bfc\u586b\u5145\u7a7a\u683c<\/td><\/tr><tr><td><code>#<\/code><\/td><td>\u628a\u7ed3\u679c\u8f6c\u6362\u4e3a\u53e6\u4e00\u79cd\u683c\u5f0f\u3002\u5982\u679c\u662f<code>%o<\/code>\u683c\u5f0f\uff0c\u5219\u4ee50\u5f00\u59cb\uff0c<code>%x<\/code>\u6216<code>%X<\/code>\u683c\u5f0f\uff0c\u5219\u4ee5<code>0x<\/code>\u6216<code>0X<\/code>\u5f00\u59cb\uff1b\u5bf9\u4e8e\u6240\u6709\u6d6e\u70b9\u683c\u5f0f\uff0c<code>#<\/code>\u4fdd\u8bc1\u5373\u4f7f\u6ca1\u6709\u5c0f\u6570\u90e8\u5206\uff0c\u4e5f\u5c06\u6253\u5370\u4e00\u4e2a\u5c0f\u6570\u70b9\u5b57\u7b26\uff1b\u5bf9\u4e8e<code>%g<\/code>\u6216<code>%G<\/code>\uff0c\u9632\u6b62\u7ed3\u679c\u540e\u9762\u76840\u500d\u5220\u9664<\/td><\/tr><tr><td><code>0<\/code><\/td><td>\u5bf9\u4e8e\u6570\u503c\u683c\u5f0f\uff0c\u7528\u524d\u5bfc0\u586b\u5145\u5b57\u6bb5\u5bbd\u5ea6\uff1b\u5bf9\u4e8e\u6574\u6570\u683c\u5f0f\uff0c\u5982\u679c\u51fa\u73b0<code>-<\/code>\u6807\u8bb0\u6216\u6307\u5b9a\u7cbe\u5ea6\uff0c\u5219\u864e\u843d\u8be5\u6807\u8bb0<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><em><code>printf()<\/code>\u7684\u4fee\u9970\u7b26<\/em><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u4fee\u9970\u7b26<\/th><th>\u610f\u4e49<\/th><\/tr><\/thead><tbody><tr><td>\u6807\u8bb0<\/td><td>\u53ef\u4ee5\u4e0d\u4f7f\u7528\u6807\u8bb0\u6216\u4f7f\u7528\u591a\u4e2a\u6807\u8bb0<\/td><\/tr><tr><td>\u6570\u5b57<\/td><td>\u6700\u5c0f\u5b57\u6bb5\u5bbd\u5ea6\u3002<br>\u5982\u679c\u5b57\u6bb5\u5c0f\u4e8e\u6307\u5b9a\u5bbd\u5ea6\uff0c\u5219\u4f1a\u8fdb\u884c\u586b\u5145\uff0c\u586b\u5145\u5185\u5bb9\u53d7\u6807\u8bb0\u5f71\u54cd\uff0c\u9ed8\u8ba4\u4e3a\u7a7a\u683c\uff1b<br>\u5982\u679c\u5b57\u6bb5\u5927\u4e8e\u6307\u5b9a\u5bbd\u5ea6\uff0c\u5219\u4f7f\u7528\u80fd\u5b8c\u6574\u663e\u793a\u7684\u6700\u5c0f\u5bbd\u5ea6<\/td><\/tr><tr><td><code>.\u6570\u5b57<\/code><\/td><td>\u7cbe\u5ea6\u3002<br>\u5bf9\u4e8e<code>%e<\/code>\u3001<code>%E<\/code>\u548c<code>%f<\/code>\uff0c\u8868\u793a\u5c0f\u6570\u70b9\u53f3\u8fb9\u6570\u5b57\u7684\u4f4d\u6570<br>\u5bf9\u4e8e<code>%g<\/code>\u548c<code>%G<\/code>\u8f6c\u6362\uff0c\u8868\u793a\u6709\u6548\u6570\u5b57\u7684\u6700\u5927\u4f4d\u6570<br>\u5bf9\u4e8e<code>%s<\/code>\u8f6c\u6362\uff0c\u8868\u793a\u5f85\u6253\u5370\u5b57\u7b26\u7684\u6700\u5927\u6570\u91cf<br>\u5bf9\u4e8e\u6574\u578b\u8f6c\u6362\uff0c\u8868\u793a\u5f85\u6253\u5370\u6570\u5b57\u7684\u6700\u5c0f\u4f4d\u6570<br>\u5982\u6709\u5fc5\u8981\uff0c\u4f7f\u7528\u524d\u5bfc0\u6765\u8fbe\u5230\u8fd9\u4e2a\u4f4d\u6570<br><code>.<\/code>\u548c<code>.0<\/code>\u76f8\u540c<\/td><\/tr><tr><td><code>h<\/code><\/td><td>\u548c\u6574\u578b\u8f6c\u6362\u8bf4\u660e\u4e00\u8d77\u4f7f\u7528\uff0c\u8868\u793a<code>short int<\/code>\u6216<code>unsigned short int<\/code>\u7c7b\u578b\u7684\u503c<\/td><\/tr><tr><td><code>hh<\/code><\/td><td>\u548c\u6574\u578b\u8f6c\u6362\u8bf4\u660e\u4e00\u8d77\u4f7f\u7528\uff0c\u8868\u793a<code>signed char<\/code>\u6216<code>unsigned char<\/code>\u7c7b\u578b\u7684\u503c<\/td><\/tr><tr><td><code>j<\/code><\/td><td>\u548c\u6574\u578b\u8f6c\u6362\u8bf4\u660e\u4e00\u8d77\u4f7f\u7528\uff0c\u8868\u793a<code>intmax_t<\/code>\u6216<code>uintmax_t<\/code>\u7c7b\u578b\u7684\u503c\uff0c\u8fd9\u4e9b\u7c7b\u578b\u5b9a\u4e49\u5728<code>stdint.h<\/code>\u4e2d<\/td><\/tr><tr><td><code>l<\/code><\/td><td>\u548c\u6574\u578b\u8f6c\u6362\u8bf4\u660e\u4e00\u8d77\u4f7f\u7528\uff0c\u8868\u793a<code>long int<\/code>\u6216<code>unsigned long int<\/code>\u7c7b\u578b\u7684\u503c<br>\u548c\u6d6e\u70b9\u8f6c\u6362\u8bf4\u660e\u4e00\u8d77\u4f7f\u7528\uff0c\u8868\u793a<code>double long<\/code>\u7c7b\u578b\u7684\u503c<\/td><\/tr><tr><td><code>ll<\/code><\/td><td>\u548c\u6574\u578b\u8f6c\u6362\u8bf4\u660e\u4e00\u8d77\u4f7f\u7528\uff0c\u8868\u793a<code>long long int<\/code>\u6216<code>unsigned long long int<\/code>\u7c7b\u578b\u7684\u503c\uff08C99\uff09<\/td><\/tr><tr><td><code>t<\/code><\/td><td>\u548c\u6574\u578b\u8f6c\u6362\u8bf4\u660e\u4e00\u8d77\u4f7f\u7528\uff0c\u8868\u793a<code>ptrdiff_t<\/code>\u7c7b\u578b\u7684\u503c\uff0c<code>ptrdiff_t<\/code>\u662f\u4e24\u4e2a\u6307\u9488\u5dee\u503c\u7684\u7c7b\u578b\uff08C99\uff09<\/td><\/tr><tr><td><code>z<\/code><\/td><td>\u548c\u6574\u578b\u8f6c\u6362\u8bf4\u660e\u4e00\u8d77\u4f7f\u7528\uff0c\u8868\u793a<code>size_t<\/code>\u7c7b\u578b\u7684\u503c\u3002<code>size_t<\/code>\u662f<code>sizeof<\/code>\u8fd4\u56de\u7684\u7c7b\u578b\uff08C99\uff09<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">3.2 \u4f7f\u7528<code>scanf()<\/code><\/h3>\n\n\n\n<p><code>scanf()<\/code>\u51fd\u6570\u4f7f\u7528\u6307\u5411\u53d8\u91cf\u7684\u6307\u9488\uff0c\u4e0d\u8fc7\u8fd9\u91cc\u5148\u4e0d\u5199\u6307\u9488\u65b9\u9762\u7684\u5185\u5bb9\u3002\u53ea\u9700\u8981\u8bb0\u4f4f\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5982\u679c\u7528<code>scanf()<\/code>\u8bfb\u53d6\u57fa\u672c\u53d8\u91cf\u7c7b\u578b\u7684\u503c\uff0c\u9700\u8981\u5728\u53d8\u91cf\u540d\u524d\u52a0\u4e00\u4e2a<code>&amp;<\/code><\/li>\n\n\n\n<li>\u5982\u679c\u7528<code>scanf()<\/code>\u5427\u5b57\u7b26\u4e32\u8bfb\u5165\u5b57\u7b26\u6570\u7ec4\u4e2d\uff0c\u4e0d\u8981\u4f7f\u7528<code>&amp;<\/code><\/li>\n<\/ol>\n\n\n\n<p><em>ANSI C\u4e2d\u7684<code>scanf()<\/code>\u7684\u8f6c\u6362\u8bf4\u660e<\/em><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u8f6c\u6362\u8bf4\u660e<\/th><th>\u542b\u4e49<\/th><\/tr><\/thead><tbody><tr><td><code>%c<\/code><\/td><td>\u628a\u8f93\u5165\u89e3\u91ca\u6210\u5b57\u7b26<\/td><\/tr><tr><td><code>%d<\/code><\/td><td>\u628a\u8f93\u5165\u89e3\u91ca\u6210\u6709\u7b26\u53f7\u7684\u5341\u8fdb\u5236\u6574\u6570<\/td><\/tr><tr><td><code>%e<\/code>\u3001<code>%f<\/code>\u3001<code>%g<\/code>\u3001<code>%a<\/code><br><code>%E<\/code>\u3001<code>%F<\/code>\u3001<code>%G<\/code>\u3001<code>%A<\/code><\/td><td>\u628a\u8f93\u5165\u89e3\u91ca\u6210\u6d6e\u70b9\u6570\uff08C99\u6807\u51c6\u65b0\u589e\u4e86<code>%a<\/code>\u548c<code>%A<\/code>\uff09<\/td><\/tr><tr><td><code>%i<\/code><\/td><td>\u628a\u8f93\u5165\u89e3\u91ca\u6210\u6709\u7b26\u53f7\u5341\u8fdb\u5236\u6574\u6570<\/td><\/tr><tr><td><code>%o<\/code><\/td><td>\u628a\u8f93\u5165\u89e3\u91ca\u6210\u6709\u7b26\u53f7\u516b\u8fdb\u5236\u6574\u6570<\/td><\/tr><tr><td><code>%p<\/code><\/td><td>\u628a\u8f93\u5165\u89e3\u91ca\u6210\u6307\u9488\uff08\u5730\u5740\uff09<\/td><\/tr><tr><td><code>%s<\/code><\/td><td>\u628a\u8f93\u5165\u89e3\u91ca\u6210\u5b57\u7b26\u4e32\uff0c\u4ece\u7b2c1\u4e2a\u975e\u7a7a\u767d\u5b57\u7b26\u5f00\u59cb\uff0c\u5230\u4e0b\u4e00\u4e2a\u975e\u7a7a\u767d\u4e4b\u524d\u7684\u6240\u6709\u5b57\u7b26\u90fd\u662f\u8f93\u5165<\/td><\/tr><tr><td><code>%u<\/code><\/td><td>\u628a\u8f93\u5165\u89e3\u91ca\u6210\u65e0\u7b26\u53f7\u5341\u8fdb\u5236\u6574\u6570<\/td><\/tr><tr><td><code>%x<\/code>\u3001<code>%X<\/code><\/td><td>\u628a\u8f93\u5165\u89e3\u91ca\u6210\u6709\u7b26\u53f7\u5341\u516d\u8fdb\u5236\u6574\u6570<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u53ef\u4ee5\u5728\u8f6c\u6362\u8bf4\u660e\u4e2d\u4f7f\u7528\u4fee\u9970\u7b26\u3002\u82e5\u8981\u4f7f\u7528\u591a\u4e2a\u4fee\u9970\u7b26\uff0c\u5219\u5fc5\u987b\u6309\u8868\u4e2d\u987a\u5e8f\u4e66\u5199<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u8f6c\u6362\u8bf4\u660e<\/th><th>\u542b\u4e49<\/th><\/tr><\/thead><tbody><tr><td><code>*<\/code><\/td><td>\u6291\u5236\u8d4b\u503c<\/td><\/tr><tr><td>\u6570\u5b57<\/td><td>\u6700\u5927\u5b57\u6bb5\u5bbd\u5ea6\u3002\u8f93\u5165\u8fbe\u5230\u6700\u5927\u5b57\u6bb5\u5bbd\u5ea6\u5904\uff0c\u6216\u7b2c1\u6b21\u9047\u5230\u7a7a\u767d\u5b57\u7b26\u65f6\u505c\u6b62<\/td><\/tr><tr><td><code>hh<\/code><\/td><td>\u628a\u6574\u6570\u4f5c\u4e3a<code>signed char<\/code>\u6216<code>unsigned char<\/code>\u7c7b\u578b\u8bfb\u53d6<\/td><\/tr><tr><td><code>ll<\/code><\/td><td>\u628a\u6574\u6570\u4f5c\u4e3a<code>long long<\/code>\u6216<code>unsigned long long<\/code>\u7c7b\u578b\u8bfb\u53d6\uff08C99\u65b0\u589e\uff09<\/td><\/tr><tr><td><code>h<\/code>\u3001<code>l<\/code>\u6216<code>L<\/code><\/td><td><code>%hd<\/code>\u548c<code>%hi<\/code>\u8868\u660e\u628a\u5bf9\u5e94\u7684\u503c\u50a8\u5b58\u4e3a<code>short int<\/code>\u7c7b\u578b<br><code>%ho<\/code>\u3001<code>%hx<\/code>\u548c<code>%hu<\/code>\u8868\u660e\u628a\u5bf9\u5e94\u7684\u503c\u50a8\u5b58\u4e3a<code>unsigned short int<\/code>\u7c7b\u578b<br><code>%ld<\/code>\u548c<code>%li<\/code>\u8868\u660e\u628a\u5bf9\u5e94\u7684\u503c\u50a8\u5b58\u4e3a<code>long<\/code>\u7c7b\u578b<br><code>%lo<\/code>\u3001<code>%lx<\/code>\u548c<code>%lu<\/code>\u8868\u660e\u628a\u5bf9\u5e94\u7684\u503c\u50a8\u5b58\u4e3a<code>unsigned long<\/code>\u7c7b\u578b<br><code>%le<\/code>\u3001<code>%lf<\/code>\u548c<code>%lg<\/code>\u8868\u660e\u628a\u5bf9\u5e94\u7684\u503c\u50a8\u5b58\u4e3a<code>double<\/code>\u7c7b\u578b<br>\u5728<code>e<\/code>\u3001<code>f<\/code>\u548c<code>g<\/code>\u524d\u9762\u4f7f\u7528<code>L<\/code>\uff0c\u8868\u660e\u628a\u5bf9\u5e94\u7684\u503c\u50a8\u5b58\u4e3a<code>long double<\/code>\u7c7b\u578b\uff0c\u5982\u679c\u6ca1\u6709\u4fee\u9970\u7b26\uff0c<code>d<\/code>\u3001<code>i<\/code>\u3001<code>o<\/code>\u548c<code>x<\/code>\u8868\u660e\u628a\u5bf9\u5e94\u7684\u503c\u50a8\u5b58\u4e3a<code>int<\/code>\u7c7b\u578b\uff0c<code>f<\/code>\u548c<code>g<\/code>\u8868\u660e\u628a\u5bf9\u5e94\u7684\u503c\u50a8\u5b58\u4e3a<code>float<\/code>\u7c7b\u578b<\/td><\/tr><tr><td><code>j<\/code><\/td><td>\u5728\u6574\u578b\u8f6c\u6362\u8bf4\u660e\u540e\u9762\u65f6\uff0c\u8868\u660e\u4f7f\u7528<code>intmax_t<\/code>\u6216<code>uintmax_t<\/code>\u7c7b\u578b\uff08C99\u65b0\u589e\uff09<\/td><\/tr><tr><td><code>z<\/code><\/td><td>\u5728\u6574\u578b\u8f6c\u6362\u8bf4\u660e\u540e\u9762\u65f6\uff0c\u8868\u660e\u4f7f\u7528<code>sizeof<\/code>\u7684\u8fd4\u56de\u7c7b\u578b\uff08C99\u65b0\u589e\uff09<\/td><\/tr><tr><td><code>t<\/code><\/td><td>\u5728\u6574\u578b\u8f6c\u6362\u8bf4\u660e\u540e\u9762\u65f6\uff0c\u8868\u660e\u4f7f\u7528\u4e24\u4e2a\u6307\u9488\u5dee\u503c\u7684\u7c7b\u578b\uff08C99\u65b0\u589e\uff09<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">3.2.1 \u4ece<code>scanf()<\/code>\u89d2\u5ea6\u770b\u8f93\u5165<\/h4>\n\n\n\n<p>\u5047\u8bbe<code>scanf()<\/code>\u6839\u636e\u4e00\u4e2a<code>%d<\/code>\u8f6c\u6362\u8bf4\u660e\u8bfb\u53d6\u4e00\u4e2a\u6574\u6570\uff0c\u90a3\u5b83\u4f1a\u5148\u8bfb\u53d6\u7b2c\u4e00\u4e2a\u975e\u7a7a\u767d\u5b57\u7b26\uff0c\u5982\u679c\u8be5\u5b57\u7b26\u662f\u6570\u5b57\u6216\u7b26\u53f7\uff0c\u4fbf\u5b58\u4e0b\u8be5\u5b57\u7b26\uff0c\u7ee7\u7eed\u8bfb\u53d6\u4e0b\u4e00\u4e2a\u5b57\u7b26\uff0c\u76f4\u5230\u9047\u5230\u975e\u6570\u5b57\u5b57\u7b26\uff0c\u6b64\u65f6<code>scanf()<\/code>\u4f1a\u5c06\u975e\u6570\u5b57\u5b57\u7b26\u653e\u56de\u8f93\u5165\uff0c\u8fd9\u6837\u7a0b\u5e8f\u4e0b\u4e00\u6b21\u8bfb\u53d6\u8f93\u5165\u65f6\uff0c\u4f1a\u4ece\u88ab\u653e\u56de\u7684\u8fd9\u4e2a\u5b57\u7b26\u5f00\u59cb\u8bfb\u53d6\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4f7f\u7528\u5b57\u6bb5\u5bbd\u5ea6\uff0c\u90a3\u4e48\u5219\u5728\u5b57\u6bb5\u7ed3\u5c3e\u6216\u7b2c1\u4e2a\u7a7a\u767d\u5b57\u7b26\u5904\u505c\u6b62\u8bfb\u53d6\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u9047\u5230\u7684\u7b2c\u4e00\u4e2a\u975e\u7a7a\u767d\u5b57\u7b26\u4e0d\u662f\u6570\u5b57\uff0c\u6bd4\u5982<code>'A'<\/code>\uff0c\u90a3\u4e48\u4f1a\u4e0d\u8d4b\u503c\u7ed9\u53d8\u91cf\uff0c\u5982\u679c<code>scanf()<\/code>\u4e2d\u5168\u90e8\u662f<code>%d<\/code>\uff0c\u90a3\u4e48\u8bfb\u53d6\u5c31\u4f1a\u4e00\u76f4\u5361\u5728\u5b57\u7b26<code>'A'<\/code>\u4e0a\uff0c\u65e0\u6cd5\u8d8a\u8fc7\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3.2.2 \u683c\u5f0f\u5b57\u7b26\u4e32\u4e2d\u7684\u666e\u901a\u5b57\u7b26<\/h4>\n\n\n\n<p><code>scanf()<\/code>\u51fd\u6570\u5141\u8bb8\u5427\u666e\u901a\u5b57\u7b26\u653e\u5728\u683c\u5f0f\u5b57\u7b26\u4e32\u4e2d\u3002\u9664\u7a7a\u683c\u5b57\u7b26\u5916\u7684\u666e\u901a\u5b57\u7b26\u5fc5\u987b\u4e0e\u8f93\u5165\u5b57\u7b26\u4e32\u4e25\u683c\u5339\u914d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scanf(\"%d,%d\", &amp;n, &amp;m);\n<\/code><\/pre>\n\n\n\n<p><code>scanf()<\/code>\u51fd\u6570\u5c06\u5176\u89e3\u91ca\u4e3a\u7528\u6237\u5c06\u8f93\u5165\u4e00\u4e2a\u6570\u5b57\u3001\u4e00\u4e2a\u9017\u53f7\u548c\u4e00\u4e2a\u6570\u5b57\u3002\u4e5f\u5c31\u662f\u8bf4\u7528\u6237\u5fc5\u987b\u7528\u9017\u53f7\u5206\u9694\u8f93\u5165\u7684\u4e24\u4e2a\u6570\u5b57\u3002<\/p>\n\n\n\n<p>\u683c\u5f0f\u5b57\u7b26\u4e32\u4e2d\u7684\u7a7a\u683c\u610f\u5473\u7740\u8df3\u8fc7\u4e0b\u4e00\u4e2a\u8f93\u5165\u9879\u524d\u9762\u7684\u6240\u6709\u7a7a\u767d\uff0c\u8fd9\u5305\u62ec\u201c\u6ca1\u6709\u7a7a\u767d\u201d\u7684\u60c5\u51b5\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3.2.3 <code>scanf()<\/code>\u8fd4\u56de\u503c<\/h4>\n\n\n\n<p><code>scanf()<\/code>\u8fd4\u56de\u6210\u529f\u8bfb\u53d6\u7684\u9879\u6570<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.3 <code>printf()<\/code>\u548c<code>scanf()<\/code>\u7684<code>*<\/code>\u4fee\u9970\u7b26<\/h3>\n\n\n\n<p><code>printf()<\/code>\u4e2d\u4f7f\u7528<code>*<\/code>\u4fee\u9970\u7b26\u6765\u4ee3\u66ff\u5b57\u6bb5\u5bbd\u5ea6\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b83\u8ba9\u7a0b\u5e8f\u6765\u6307\u5b9a\u5b57\u6bb5\u5bbd\u5ea6\uff0c\u800c\u4e0d\u9700\u8981\u4f60\u4e8b\u5148\u9884\u8bbe\u3002\u8fd9\u70b9\u540c\u6837\u53ef\u4ee5\u5e94\u7528\u4e8e\u6d6e\u70b9\u503c\u6307\u5b9a\u7cbe\u5ea6\u548c\u5b57\u6bb5\u5bbd\u5ea6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nint main(void) {\n    unsigned width, precision;\n    int number = 256;\n    double weight = 242.5;\n    \n    printf(\"Enter a field width:\\n\");\n    scanf(\"%d\", &amp;width);\n    printf(\"The number is : %*d\\n\", width, number);\n    printf(\"Now there a width and a precision:\\n\");\n    scanf(\"%d %d\", &amp;width, &amp;precision);\n    printf(\"Weight = %*.*f\\n\", width, precision, weight);\n    printf(\"Done!\\n\");\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<p><code>scanf()<\/code>\u4e2d\uff0c\u628a<code>*<\/code>\u653e\u5728<code>%<\/code>\u548c\u8f6c\u6362\u5b57\u7b26\u4e4b\u95f4\u65f6\uff0c\u4f1a\u4f7f\u5f97<code>scanf()<\/code>\u8df3\u8fc7\u76f8\u5e94\u7684\u8f93\u51fa\u9879\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nint main(void) {\n    int n;\n    printf(\"Please enter three integers:\\n\");\n    scanf(\"%*d %*d %d\", &amp;n);\n    printf(\"The last integer was %d\\n\", n);\n    return 0;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5b57\u7b26\u4e32 \u5b57\u7b26\u4e32\u662f\u4e00\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u7684\u5e8f\u5217\u3002\u53cc\u5f15\u53f7\u4e0d\u662f\u5b57\u7b26\u4e32\u7684\u4e00\u90e8\u5206\uff0c\u5b83\u7684\u4f5c\u7528\u4ec5\u662f\u544a\u8bc9\u7f16\u8bd1\u5668\u5b83\u62ec\u8d77\u6765\u7684\u5185\u5bb9\u662f\u5b57 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[11],"class_list":["post-49","post","type-post","status-publish","format-standard","hentry","category-c-2","tag-c-2"],"_links":{"self":[{"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/posts\/49","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/comments?post=49"}],"version-history":[{"count":6,"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/posts\/49\/revisions"}],"predecessor-version":[{"id":64,"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/posts\/49\/revisions\/64"}],"wp:attachment":[{"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/media?parent=49"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/categories?post=49"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.caldm.cn\/index.php\/wp-json\/wp\/v2\/tags?post=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}