{"id":12334,"date":"2023-04-04T04:09:34","date_gmt":"2023-04-03T20:09:34","guid":{"rendered":"https:\/\/www.linuxcool.com\/qszwlmlpdgsh"},"modified":"2023-04-04T04:09:34","modified_gmt":"2023-04-03T20:09:34","slug":"qszwlmlpdgsh","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/qszwlmlpdgsh","title":{"rendered":"\u8f7b\u677e\u638c\u63e1Linux\u547d\u4ee4printf\u7684\u683c\u5f0f\u5316\u8f93\u51fa\u65b9\u6cd5"},"content":{"rendered":"<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5728<a style='color:#0000CC' href='https:\/\/www.linuxprobe.com\/' target='_blank' rel=\"noopener\">Linux<\/a><a style='color:#0000CC' href='https:\/\/www.linuxdown.com\/' target='_blank' rel=\"noopener\">\u7cfb\u7edf<\/a>\u4e2d\uff0c\u6709\u5f88\u591a\u5e38\u7528\u7684<a style='color:#0000CC' href='https:\/\/www.linuxcool.com\/' target='_blank' rel=\"noopener\">\u547d\u4ee4<\/a>\uff0c\u5176\u4e2dprintf\u662f\u4e00\u4e2a\u975e\u5e38\u5b9e\u7528\u7684\u547d\u4ee4\uff0c\u5b83\u53ef\u4ee5\u8f93\u51fa\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\uff0c\u5e76\u4e14\u683c\u5f0f\u5316\u7684\u65b9\u5f0f\u975e\u5e38\u7075\u6d3b\uff0c\u53ef\u4ee5\u6ee1\u8db3\u5404\u79cd\u8f93\u51fa\u9700\u6c42\u3002\u4eca\u5929\uff0c\u6211\u4eec\u5c31\u6765\u6df1\u5165\u4e86\u89e3\u4e00\u4e0b\u8fd9\u4e2a\u547d\u4ee4\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>1. printf\u547d\u4ee4\u7684\u57fa\u672c\u8bed\u6cd5<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5728\u4f7f\u7528printf\u547d\u4ee4\u65f6\uff0c\u6211\u4eec\u9700\u8981\u6307\u5b9a\u8f93\u51fa\u7684\u683c\u5f0f\u548c\u5185\u5bb9\u3002\u5176\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\nprintf &quot;\u683c\u5f0f\u5316\u5b57\u7b26\u4e32&quot;\u53c2\u65701\u53c2\u65702...\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5176\u4e2d\uff0c\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u662f\u5fc5\u987b\u8981\u6307\u5b9a\u7684\uff0c\u5b83\u7528\u4e8e\u6307\u5b9a\u8f93\u51fa\u7684\u683c\u5f0f\u3002\u800c\u540e\u9762\u8ddf\u7740\u7684\u53c2\u6570\u5219\u662f\u53ef\u9009\u7684\uff0c\u5b83\u4eec\u4f1a\u6309\u7167\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u4e2d\u7684\u683c\u5f0f\u8fdb\u884c\u8f93\u51fa\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>2.\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u4e2d\u7684\u8f6c\u4e49\u5b57\u7b26<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5728\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u7279\u6b8a\u5b57\u7b26\u6765\u63a7\u5236\u8f93\u51fa\u683c\u5f0f\u3002\u8fd9\u4e9b\u7279\u6b8a\u5b57\u7b26\u901a\u5e38\u4ee5\u53cd\u659c\u6760\uff08\uff09\u5f00\u5934\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u8f6c\u4e49\u5b57\u7b26\u53ca\u5176\u542b\u4e49\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><img style='max-height:350px;max-width:80%;margin: 10px auto' src='https:\/\/www.linuxcool.com\/wp-content\/uploads\/2023\/04\/1680552573932_0.png' alt='linux\u547d\u4ee4printf\u4ec0\u4e48\u610f\u601d_linux -printf_linux\u547d\u4ee4\u4e2d\u7684head\u547d\u4ee4' \/><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>-n\uff1a\u6362\u884c\u7b26<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>-t\uff1a\u5236\u8868\u7b26<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>-\\\uff1a\u53cd\u659c\u6760<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>-b\uff1a\u9000\u683c\u7b26<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>-r\uff1a\u56de\u8f66\u7b26<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>3.\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u4e2d\u7684\u5360\u4f4d\u7b26<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u9664\u4e86\u8f6c\u4e49\u5b57\u7b26\u4e4b\u5916linux\u7cfb\u7edf\u5e94\u7528\uff0c\u5728\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u4e2d\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5360\u4f4d\u7b26\u6765\u6307\u5b9a\u8f93\u51fa\u5185\u5bb9\u7684\u7c7b\u578b\u548c\u5bbd\u5ea6\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5360\u4f4d\u7b26\u53ca\u5176\u542b\u4e49\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>-%s\uff1a\u5b57\u7b26\u4e32\u7c7b\u578b<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>-%d\uff1a\u5341\u8fdb\u5236\u6574\u6570\u7c7b\u578b<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>-%x\uff1a\u5341\u516d\u8fdb\u5236\u6574\u6570\u7c7b\u578b\uff08\u5c0f\u5199\u5b57\u6bcd\uff09<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>-%X\uff1a\u5341\u516d\u8fdb\u5236\u6574\u6570\u7c7b\u578b\uff08\u5927\u5199\u5b57\u6bcd\uff09<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>-%f\uff1a\u6d6e\u70b9\u6570\u7c7b\u578b<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>-%e\uff1a\u79d1\u5b66\u8ba1\u6570\u6cd5\u8868\u793a\u7684\u6d6e\u70b9\u6570\u7c7b\u578b\uff08\u5c0f\u5199\u5b57\u6bcd\uff09<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>-%E\uff1a\u79d1\u5b66\u8ba1\u6570\u6cd5\u8868\u793a\u7684\u6d6e\u70b9\u6570\u7c7b\u578b\uff08\u5927\u5199\u5b57\u6bcd\uff09<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><img style='max-height:350px;max-width:80%;margin: 10px auto' src='https:\/\/www.linuxcool.com\/wp-content\/uploads\/2023\/04\/1680552573932_2.webp' alt='linux\u547d\u4ee4printf\u4ec0\u4e48\u610f\u601d_linux -printf_linux\u547d\u4ee4\u4e2d\u7684head\u547d\u4ee4' \/><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5728\u4f7f\u7528\u5360\u4f4d\u7b26\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a\u5bbd\u5ea6\u548c\u7cbe\u5ea6\u3002\u5bbd\u5ea6\u6307\u5b9a\u8f93\u51fa\u5185\u5bb9\u7684\u6700\u5c0f\u5bbd\u5ea6<strong>linux\u547d\u4ee4printf\u4ec0\u4e48\u610f\u601d<\/strong>\uff0c\u5982\u679c\u5185\u5bb9\u4e0d\u8db3\uff0c\u5219\u7528\u7a7a\u683c\u586b\u5145\uff1b\u7cbe\u5ea6\u5219\u7528\u4e8e\u63a7\u5236\u6d6e\u70b9\u6570\u8f93\u51fa\u7684\u5c0f\u6570\u4f4d\u6570\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>4.\u5b9e\u4f8b\u6f14\u793a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u4e3a\u4e86\u66f4\u597d\u5730\u7406\u89e3printf\u547d\u4ee4\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u4e0b\u9762\u6211\u4eec\u6765\u770b\u4e00\u4e9b\u5b9e\u4f8b\u6f14\u793a\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u4f8b1\uff1a\u8f93\u51fa\u5b57\u7b26\u4e32<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\nprintf &quot;Hello, world!n&quot;\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\nHello, world!\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u4f8b2\uff1a\u8f93\u51fa\u6574\u6570<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\nprintf &quot;%dn&quot; 100\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n100\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u4f8b3\uff1a\u8f93\u51fa\u6d6e\u70b9\u6570<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\nprintf &quot;%.2fn&quot;3.1415\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><img style='max-height:350px;max-width:80%;margin: 10px auto' src='https:\/\/www.linuxcool.com\/wp-content\/uploads\/2023\/04\/1680552573932_4.jpg' alt='linux\u547d\u4ee4\u4e2d\u7684head\u547d\u4ee4_linux\u547d\u4ee4printf\u4ec0\u4e48\u610f\u601d_linux -printf' \/><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n3.14\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u4f8b4\uff1a\u6307\u5b9a\u5bbd\u5ea6\u548c\u7cbe\u5ea6<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\nprintf &quot;%8.2fn&quot;3.1415\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n    3.14\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>5.\u603b\u7ed3\u4e0e\u5c55\u671b<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u6211\u4eec\u4e86\u89e3\u4e86Linux\u547d\u4ee4printf\u7684\u57fa\u672c\u8bed\u6cd5\u3001\u8f6c\u4e49\u5b57\u7b26\u548c\u5360\u4f4d\u7b26\u7b49\u76f8\u5173\u77e5\u8bc6\u3002\u540c\u65f6\uff0c\u6211\u4eec\u4e5f\u770b\u5230\u4e86printf\u547d\u4ee4\u7684\u5b9e\u9645\u5e94\u7528\u573a\u666flinux makefile\uff0c\u5e76\u901a\u8fc7\u5b9e\u4f8b\u6f14\u793a\u66f4\u597d\u5730\u7406\u89e3\u4e86\u5176\u4f7f\u7528\u65b9\u6cd5\u3002\u5728\u65e5\u5e38\u5de5\u4f5c\u4e2d\uff0c\u638c\u63e1printf\u547d\u4ee4\u7684\u4f7f\u7528\u65b9\u6cd5<strong>linux\u547d\u4ee4printf\u4ec0\u4e48\u610f\u601d<\/strong>\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u52a0\u9ad8\u6548\u5730\u5b8c\u6210\u5404\u79cd\u6587\u672c\u5904\u7406\u4efb\u52a1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6709\u5f88\u591a\u5e38\u7528\u7684\u547d\u4ee4\uff0c\u5176\u4e2dprintf\u662f\u4e00\u4e2a\u975e\u5e38\u5b9e\u7528\u7684\u547d\u4ee4\uff0c\u5b83\u53ef\u4ee5\u8f93\u51fa\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\uff0c\u5e76\u4e14\u683c\u5f0f\u5316\u7684\u65b9\u5f0f\u975e\u5e38\u7075\u6d3b\uff0c\u53ef\u4ee5\u6ee1\u8db3\u5404\u79cd\u8f93\u51fa\u9700\u6c42\u3002printf\u547d\u4ee4\u7684\u57fa\u672c\u8bed\u6cd5\u5728\u4f7f\u7528printf\u547d\u4ee4\u65f6\uff0c\u6211\u4eec\u9700\u8981\u6307\u5b9a\u8f93\u51fa\u7684\u683c\u5f0f\u548c\u5185\u5bb9\u3002\u800c\u540e\u9762\u8ddf\u7740\u7684\u53c2\u6570\u5219\u662f\u53ef\u9009\u7684\uff0c\u5b83\u4eec\u4f1a\u6309\u7167\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u4e2d\u7684\u683c\u5f0f\u8fdb\u884c\u8f93\u51fa\u3002\u5728\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u7279\u6b8a\u5b57\u7b26\u6765\u63a7\u5236\u8f93\u51fa\u683c\u5f0f\u3002<\/p>\n","protected":false},"author":1,"featured_media":12335,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[483,484,485],"class_list":["post-12334","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledge","tag-p-11","tag-fds","tag-zy-2"],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/12334","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=12334"}],"version-history":[{"count":0,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/12334\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media\/12335"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=12334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=12334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=12334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}