{"id":29659,"date":"2023-05-14T13:13:24","date_gmt":"2023-05-14T05:13:24","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=29659"},"modified":"2023-07-31T01:45:52","modified_gmt":"2023-07-30T17:45:52","slug":"c%e7%9a%84%e5%ad%97%e9%9d%a2%e5%80%bc%e5%b8%b8%e9%87%8f%e6%98%af%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/29659.html","title":{"rendered":"C++\u7684\u5b57\u9762\u503c\u5e38\u91cf\u662f\u4ec0\u4e48"},"content":{"rendered":"<blockquote class=\"wp-block-quote\">\n<p>C++\u4e2d\u7684\u5b57\u9762\u503c\u5e38\u91cf\u662f\u6307\u5728\u7a0b\u5e8f\u4e2d\u76f4\u63a5\u4f7f\u7528\u7684\u7279\u5b9a\u503c\u3002\u8fd9\u4e9b\u5e38\u91cf\u53ef\u4ee5\u662f\u6574\u578b\u3001\u6d6e\u70b9\u578b\u3001\u5b57\u7b26\u3001\u5b57\u7b26\u4e32\u548c\u5e03\u5c14\u503c\u3002\u5b83\u4eec\u5728\u7f16\u7a0b\u4e2d\u8d77\u5230\u4ee3\u8868\u7279\u5b9a\u503c\u7684\u4f5c\u7528\uff0c\u4f8b\u5982\uff0c\u6570\u5b577\u5c31\u662f\u4e00\u4e2a\u6574\u578b\u5b57\u9762\u503c\u5e38\u91cf\uff0c\u5b57\u7b26\u2019A\u2019\u662f\u4e00\u4e2a\u5b57\u7b26\u5b57\u9762\u503c\u5e38\u91cf\uff0c\u201dHello World\u201d\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u5b57\u9762\u503c\u5e38\u91cf\u3002\u8fd9\u4e9b\u5b57\u9762\u503c\u5e38\u91cf\u5728\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u7684\u503c\u662f\u4e0d\u80fd\u88ab\u6539\u53d8\u7684\u3002<\/p>\n<\/blockquote>\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" alt=\"\" class=\"wp-image-29660\" decoding=\"async\" height=\"576\" sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/05\/\u6a21\u677f2-17-1024x576.png?x-oss-process=image\/auto-orient,1\/format,webp\" srcset=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/05\/\u6a21\u677f2-17-1024x576.png?x-oss-process=image\/auto-orient,1\/format,webp 1024w, https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/05\/\u6a21\u677f2-17-300x169.png 300w, https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/05\/\u6a21\u677f2-17-768x432.png 768w, https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/05\/\u6a21\u677f2-17-270x152.png 270w, https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/05\/\u6a21\u677f2-17-1536x865.png 1536w, https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/05\/\u6a21\u677f2-17.png 1993w\" width=\"1024\"\/><\/figure>\n<h2 class=\"wp-block-heading\">\u4e00\u3001C++\u7684\u5b57\u9762\u503c\u5e38\u91cf<\/h2>\n<p>C++\u7684\u5b57\u9762\u503c\u5e38\u91cf\u662f\u5728\u6e90\u4ee3\u7801\u4e2d\u8868\u793a\u56fa\u5b9a\u503c\u7684\u7b26\u53f7\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7c7b\u578b\u7684\u5b57\u9762\u503c\u5e38\u91cf\uff1a<\/p>\n<ol>\n<li><strong>\u6574\u578b\u5b57\u9762\u503c\u5e38\u91cf<\/strong>\uff1a\u8fd9\u662f\u4e00\u79cd\u6700\u5e38\u89c1\u7684\u5b57\u9762\u503c\u7c7b\u578b\u3002\u4f8b\u5982\uff0c\u6570\u5b575\u3001100\u548c-273\u90fd\u662f\u6574\u578b\u5b57\u9762\u503c\u5e38\u91cf\u3002\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5341\u516d\u8fdb\u5236\uff08\u59820x1F\uff09\u3001\u516b\u8fdb\u5236\uff08\u5982017\uff09\u6216\u4e8c\u8fdb\u5236\uff08\u59820b1010\uff09\u8868\u793a\u6574\u6570\u3002<\/li>\n<li><strong>\u6d6e\u70b9\u578b\u5b57\u9762\u503c\u5e38\u91cf<\/strong>\uff1a\u6d6e\u70b9\u578b\u5b57\u9762\u503c\u5e38\u91cf\u7528\u4e8e\u8868\u793a\u5c0f\u6570\uff0c\u4f8b\u5982\uff0c3.14\u3001-0.001\u6216\u80051.6e-19\u3002<\/li>\n<li><strong>\u5b57\u7b26\u5b57\u9762\u503c\u5e38\u91cf<\/strong>\uff1a\u5b57\u7b26\u5b57\u9762\u503c\u5e38\u91cf\u662f\u5355\u5f15\u53f7\u4e2d\u7684\u5355\u4e2a\u5b57\u7b26\uff0c\u4f8b\u5982\uff0c\u2019a\u2019\u3001\u2019Z\u2019\u6216\u20199\u2019\u3002\u8fd8\u5305\u62ec\u4e00\u4e9b\u8f6c\u4e49\u5e8f\u5217\uff0c\u5982\u2019\\n\u2019\uff08\u6362\u884c\u7b26\uff09\u3001\u2019\\t\u2019\uff08\u5236\u8868\u7b26\uff09\u548c\u2019\\0\u2019\uff08\u7a7a\u5b57\u7b26\uff09\u3002<\/li>\n<li><strong>\u5b57\u7b26\u4e32\u5b57\u9762\u503c\u5e38\u91cf<\/strong>\uff1a\u5b57\u7b26\u4e32\u5b57\u9762\u503c\u5e38\u91cf\u7531\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\u7684\u5b57\u7b26\u5e8f\u5217\u6784\u6210\uff0c\u4f8b\u5982\uff0c\u201dhello, world\u201d\u6216\u8005\u201d12345\u2033\u3002<\/li>\n<li><strong>\u5e03\u5c14\u5b57\u9762\u503c\u5e38\u91cf<\/strong>\uff1a\u5e03\u5c14\u5b57\u9762\u503c\u5e38\u91cf\u53ea\u6709\u4e24\u4e2a\uff1atrue\u548cfalse\u3002<\/li>\n<li><strong>\u7a7a\u6307\u9488\u5b57\u9762\u503c\u5e38\u91cf<\/strong>\uff1a\u7a7a\u6307\u9488\u5b57\u9762\u503c\u5e38\u91cf\u662fnullptr\u3002<\/li>\n<\/ol>\n<p>\u8fd9\u4e9b\u5b57\u9762\u503c\u5e38\u91cf\u5728\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u7684\u503c\u662f\u4e0d\u80fd\u88ab\u6539\u53d8\u7684\u3002\u5728C++\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528const\u5173\u952e\u5b57\u6765\u521b\u5efa\u5e38\u91cf\u53d8\u91cf\uff0c\u5176\u503c\u5728\u521d\u59cb\u5316\u540e\u4e5f\u4e0d\u80fd\u88ab\u6539\u53d8\u3002\u4f8b\u5982\uff0cconst int days = 7; \u8fd9\u884c\u4ee3\u7801\u521b\u5efa\u4e86\u4e00\u4e2a\u6574\u578b\u5e38\u91cfdays\uff0c\u5e76\u521d\u59cb\u5316\u4e3a\u5b57\u9762\u503c\u5e38\u91cf7\u3002<\/p>\n<p>\u5728C++11\u4e2d\uff0c\u8fd8\u5f15\u5165\u4e86\u4e00\u79cd\u65b0\u7684\u5b57\u9762\u503c\u5e38\u91cf\u7c7b\u578b\uff1a\u7528\u6237\u5b9a\u4e49\u5b57\u9762\u503c\u5e38\u91cf\u3002\u8fd9\u5141\u8bb8\u5f00\u53d1\u8005\u81ea\u5b9a\u4e49\u5b57\u9762\u503c\u5e38\u91cf\u7684\u7c7b\u578b\u548c\u503c\uff0c\u4f7f\u5f97\u4ee3\u7801\u66f4\u5177\u53ef\u8bfb\u6027\u548c\u8868\u73b0\u529b\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u8868\u793a\u65f6\u95f4\u7684\u5b57\u9762\u503c\u5e38\u91cf\uff0c\u598212h + 30min\uff0c\u8fd9\u5728\u67d0\u4e9b\u7279\u5b9a\u9886\u57df\u7684\u7f16\u7a0b\u4e2d\u975e\u5e38\u6709\u7528\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u4e8c\u3001C++ \u53d8\u91cf\u548c\u57fa\u672c\u7c7b\u578b\u3001\u5b57\u9762\u503c\u5e38\u91cf<\/h2>\n<p>\u50cf 42 \u8fd9\u6837\u7684\u503c\uff0c\u5728\u7a0b\u5e8f\u4e2d\u88ab\u5f53\u4f5c\u5b57\u9762\u503c\u5e38\u91cf\u3002\u79f0\u4e4b\u4e3a\u5b57\u9762\u503c\u662f\u56e0\u4e3a\u53ea\u80fd\u7528\u5b83\u7684\u503c\u79f0\u547c\u5b83\uff0c\u79f0\u4e4b\u4e3a\u5e38\u91cf\u662f\u56e0\u4e3a\u5b83\u7684\u503c\u4e0d\u80fd\u4fee\u6539\u3002\u6bcf\u4e2a\u5b57\u9762\u503c\u90fd\u6709\u76f8\u5e94\u7684\u7c7b\u578b\uff0c\u4f8b\u5982\uff1a0 \u662f int \u578b\uff0c3.14159 \u662f double \u578b\u3002\u53ea\u6709\u5185\u7f6e\u7c7b\u578b\u5b58\u5728\u5b57\u9762\u503c\uff0c\u6ca1\u6709\u7c7b\u7c7b\u578b\u7684\u5b57\u9762\u503c\u3002\u56e0\u6b64\uff0c\u4e5f\u6ca1\u6709\u4efb\u4f55\u6807\u51c6\u5e93\u7c7b\u578b\u7684\u5b57\u9762\u503c\u3002<\/p>\n<p><strong>\u6574\u578b\u5b57\u9762\u503c\u89c4\u5219<\/strong><\/p>\n<p>\u5b9a\u4e49\u5b57\u9762\u503c\u6574\u6570\u5e38\u91cf\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4e09\u79cd\u8fdb\u5236\u4e2d\u7684\u4efb\u4e00\u79cd\uff1a\u5341\u8fdb\u5236\u3001\u516b\u8fdb\u5236\u548c\u5341\u516d\u8fdb\u5236\u3002\u5f53\u7136\u8fd9\u4e9b\u8fdb\u5236\u4e0d\u4f1a\u6539\u53d8\u5176\u4e8c\u8fdb\u5236\u4f4d\u7684\u8868\u793a\u5f62\u5f0f\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u80fd\u5c06\u503c 20 \u5b9a\u4e49\u6210\u4e0b\u5217\u4e09\u79cd\u5f62\u5f0f\u4e2d\u7684\u4efb\u610f\u4e00\u79cd\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>20 \u00a0 \u00a0 \/\/ decimal<br \/>024 \u00a0 \u00a0\/\/ octal<br \/>0x14 \u00a0 \/\/ hexadecimal<\/p>\n<\/blockquote>\n<p>\u4ee5 0\uff08\u96f6\uff09\u5f00\u5934\u7684\u5b57\u9762\u503c\u6574\u6570\u5e38\u91cf\u8868\u793a\u516b\u8fdb\u5236\uff0c\u4ee5 0x \u6216 0X \u5f00\u5934\u7684\u8868\u793a\u5341\u516d\u8fdb\u5236\u3002<\/p>\n<p>\u5b57\u9762\u503c\u6574\u6570\u5e38\u91cf\u7684\u7c7b\u578b\u9ed8\u8ba4\u4e3a int \u6216 long \u7c7b\u578b\u3002\u5176\u7cbe\u5ea6\u7c7b\u578b\u51b3\u5b9a\u4e8e\u5b57\u9762\u503c\u2014\u2014\u5176\u503c\u9002\u5408 int \u5c31\u662f int \u7c7b\u578b\uff0c\u6bd4 int \u5927\u7684\u503c\u5c31\u662f long \u7c7b\u578b\u3002\u901a\u8fc7\u589e\u52a0\u540e\u7f00\uff0c\u80fd\u591f\u5f3a\u5236\u5c06\u5b57\u9762\u503c\u6574\u6570\u5e38\u91cf\u8f6c\u6362\u4e3a long\u3001unsigned \u6216 unsigned long \u7c7b\u578b\u3002\u901a\u8fc7\u5728\u6570\u503c\u540e\u9762\u52a0 L \u6216\u8005 l\uff08\u5b57\u6bcd\u201cl\u201d\u5927\u5199\u6216\u5c0f\u5199\uff09\u6307\u5b9a\u5e38\u91cf\u4e3a long \u7c7b\u578b\u3002<\/p>\n<p>\u5b9a\u4e49\u957f\u6574\u578b\u65f6\uff0c\u5e94\u8be5\u4f7f\u7528\u5927\u5199\u5b57\u6bcd L\u3002\u5c0f\u5199\u5b57\u6bcd l \u5f88\u5bb9\u6613\u548c\u6570\u503c 1 \u6df7\u6dc6\u3002<\/p>\n<p>\u7c7b\u4f3c\u5730\uff0c\u53ef\u901a\u8fc7\u5728\u6570\u503c\u540e\u9762\u52a0 U \u6216 u \u5b9a\u4e49 unsigned \u7c7b\u578b\u3002\u540c\u65f6\u52a0 L \u548c U \u5c31\u80fd\u591f\u5f97\u5230 unsigned long \u7c7b\u578b\u7684\u5b57\u9762\u503c\u5e38\u91cf\u3002\u4f46\u5176\u540e\u7f00\u4e0d\u80fd\u6709\u7a7a\u683c\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>128u \u00a0 \u00a0 \/* unsigned \u00a0 *\/ \u00a0 \u00a0 \u00a0 \u00a0 \u00a01024UL \u00a0 \u00a0\/* unsigned long \u00a0 *\/<br \/>1L \u00a0 \u00a0 \u00a0 \/* long \u00a0 \u00a0*\/ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 8Lu \u00a0 \u00a0 \u00a0 \u00a0\/* unsigned long \u00a0 *\/<\/p>\n<\/blockquote>\n<p>\u6ca1\u6709 short \u7c7b\u578b\u7684\u5b57\u9762\u503c\u5e38\u91cf\u3002<\/p>\n<p><strong>\u6d6e\u70b9\u5b57\u9762\u503c\u89c4\u5219<\/strong><\/p>\n<p>\u901a\u5e38\u53ef\u4ee5\u7528\u5341\u8fdb\u5236\u6216\u8005\u79d1\u5b66\u8ba1\u6570\u6cd5\u6765\u8868\u793a\u6d6e\u70b9\u5b57\u9762\u503c\u5e38\u91cf\u3002\u4f7f\u7528\u79d1\u5b66\u8ba1\u6570\u6cd5\u65f6\uff0c\u6307\u6570\u7528 E \u6216\u8005 e \u8868\u793a\u3002\u9ed8\u8ba4\u7684\u6d6e\u70b9\u5b57\u9762\u503c\u5e38\u91cf\u4e3a double \u7c7b\u578b\u3002\u5728\u6570\u503c\u7684\u540e\u9762\u52a0\u4e0a F \u6216 f \u8868\u793a\u5355\u7cbe\u5ea6\u3002\u540c\u6837\u52a0\u4e0a L \u6216\u8005 l \u8868\u793a\u6269\u5c55\u7cbe\u5ea6\uff08\u518d\u6b21\u63d0\u9192\uff0c\u4e0d\u63d0\u5021\u4f7f\u7528\u5c0f\u5199\u5b57\u6bcdl\uff09\u3002\u4e0b\u9762\u6bcf\u4e00\u7ec4\u5b57\u9762\u503c\u8868\u793a\u76f8\u540c\u7684\u503c\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>3.14159F \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0.001f \u00a0 \u00a0 \u00a0 \u00a0 \u00a012.345L \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a00.<br \/>3.14159E0f \u00a0 \u00a0 \u00a0 \u00a0 \u00a01E-3F \u00a0 \u00a0 \u00a0 \u00a0 \u00a01.2345E1L \u00a0 \u00a0 \u00a0 \u00a0 \u00a00e0<\/p>\n<\/blockquote>\n<p><strong>\u5e03\u5c14\u5b57\u9762\u503c\u548c\u5b57\u7b26\u5b57\u9762\u503c<\/strong><\/p>\n<p>\u5355\u8bcd true \u548c false \u662f\u5e03\u5c14\u578b\u7684\u5b57\u9762\u503c\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>bool test = false;<\/p>\n<\/blockquote>\n<p>\u53ef\u6253\u5370\u7684\u5b57\u7b26\u578b\u5b57\u9762\u503c\u901a\u5e38\u7528\u4e00\u5bf9\u5355\u5f15\u53f7\u6765\u5b9a\u4e49\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>\u2018a\u2019 \u00a0 \u00a0 \u00a0 \u00a0 \u20182\u2019 \u00a0 \u00a0 \u00a0 \u00a0 \u2018,\u2019 \u00a0 \u00a0 \u00a0 \u00a0 \u2018 \u2018 \/\/ blank<\/p>\n<\/blockquote>\n<p>\u8fd9\u4e9b\u5b57\u9762\u503c\u90fd\u662f char \u7c7b\u578b\u7684\u3002\u5728\u5b57\u7b26\u5b57\u9762\u503c\u524d\u52a0 L \u5c31\u80fd\u591f\u5f97\u5230 wchar_t \u7c7b\u578b\u7684\u5bbd\u5b57\u7b26\u5b57\u9762\u503c\u3002\u5982\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>L\u2019a\u2019<\/p>\n<\/blockquote>\n<p><strong>\u975e\u6253\u5370\u5b57\u7b26\u7684\u8f6c\u4e49\u5e8f\u5217<\/strong><\/p>\n<p>\u6709\u4e9b\u5b57\u7b26\u662f\u4e0d\u53ef\u6253\u5370\u7684\u3002\u4e0d\u53ef\u6253\u5370\u5b57\u7b26\u5b9e\u9645\u4e0a\u662f\u4e0d\u53ef\u663e\u793a\u7684\u5b57\u7b26\uff0c\u6bd4\u5982\u9000\u683c\u6216\u8005\u63a7\u5236\u7b26\u3002\u8fd8\u6709\u4e00\u4e9b\u5728\u8bed\u8a00\u4e2d\u6709\u7279\u6b8a\u610f\u4e49\u7684\u5b57\u7b26\uff0c\u4f8b\u5982\u5355\u5f15\u53f7\u3001\u53cc\u5f15\u53f7\u548c\u53cd\u659c\u7ebf\u7b26\u53f7\u3002\u4e0d\u53ef\u6253\u5370\u5b57\u7b26\u548c\u7279\u6b8a\u5b57\u7b26\u90fd\u7528\u8f6c\u4e49\u5b57\u7b26\u4e66\u5199\u3002\u8f6c\u4e49\u5b57\u7b26\u90fd\u4ee5\u53cd\u659c\u7ebf\u7b26\u53f7\u5f00\u59cb\uff0cC++ \u8bed\u8a00\u4e2d\u5b9a\u4e49\u4e86\u5982\u4e0b\u8f6c\u4e49\u5b57\u7b26\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>newline \u6362\u884c\u7b26<\/td>\n<td>\u00a0\\n\u00a0<\/td>\n<td>horizontal tab \u6c34\u5e73\u5236\u8868\u7b26\u00a0<\/td>\n<td>\u00a0\\t<\/td>\n<\/tr>\n<tr>\n<td>vertical tab \u7eb5\u5411\u5236\u8868\u7b26<\/td>\n<td>\u00a0\\v<\/td>\n<td>backspace \u9000\u683c\u7b26<\/td>\n<td>\u00a0\\b<\/td>\n<\/tr>\n<tr>\n<td>carriage return \u56de\u8f66\u7b26<\/td>\n<td>\u00a0\\r<\/td>\n<td>formfeed \u8fdb\u7eb8\u7b26<\/td>\n<td>\u00a0\\f<\/td>\n<\/tr>\n<tr>\n<td>alert (bell) \u62a5\u8b66\uff08\u54cd\u94c3\uff09\u7b26\u00a0<\/td>\n<td>\u00a0\\a<\/td>\n<td>backslash \u53cd\u659c\u7ebf<\/td>\n<td>\u00a0\\\\<\/td>\n<\/tr>\n<tr>\n<td>question mark \u7591\u95ee\u53f7<\/td>\n<td>\u00a0\\?<\/td>\n<td>single quote \u5355\u5f15\u53f7<\/td>\n<td>\u00a0\\\u2019<\/td>\n<\/tr>\n<tr>\n<td>double quote \u53cc\u5f15\u53f7<\/td>\n<td>\u00a0\\\u201d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<\/blockquote>\n<p>\u6211\u4eec\u53ef\u4ee5\u5c06\u4efb\u4f55\u5b57\u7b26\u8868\u793a\u4e3a\u4ee5\u4e0b\u5f62\u5f0f\u7684\u901a\u7528\u8f6c\u4e49\u5b57\u7b26\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>\\ooo<\/p>\n<\/blockquote>\n<p>\u8fd9\u91cc ooo \u8868\u793a\u4e09\u4e2a\u516b\u8fdb\u5236\u6570\u5b57\uff0c\u8fd9\u4e09\u4e2a\u6570\u5b57\u8868\u793a\u5b57\u7b26\u7684\u6570\u5b57\u503c\u3002\u4e0b\u9762\u7684\u4f8b\u5b50\u662f\u7528 ASCII \u7801\u5b57\u7b26\u96c6\u8868\u793a\u5b57\u9762\u503c\u5e38\u91cf\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>\\7 (bell) \u00a0 \u00a0 \u00a0\\12 (newline) \u00a0 \u00a0 \\40 (blank)<br \/>\\0 (null) \u00a0 \u00a0 \u00a0\\062 (\u20182\u2019) \u00a0 \u00a0 \u00a0 \u00a0\\115 (\u2018M\u2019)<\/p>\n<\/blockquote>\n<p>\u5b57\u7b26\u2019\\0\u2019\u901a\u5e38\u8868\u793a\u201c\u7a7a\u5b57\u7b26\uff08null character\uff09\u201d\uff0c\u6211\u4eec\u5c06\u4f1a\u770b\u5230\u5b83\u6709\u7740\u975e\u5e38\u7279\u6b8a\u7684\u610f\u4e49\u3002<\/p>\n<p>\u540c\u6837\u4e5f\u53ef\u4ee5\u7528\u5341\u516d\u8fdb\u5236\u8f6c\u4e49\u5b57\u7b26\u6765\u5b9a\u4e49\u5b57\u7b26\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>\\xddd<\/p>\n<\/blockquote>\n<p>\u5b83\u7531\u4e00\u4e2a\u53cd\u659c\u7ebf\u7b26\u3001\u4e00\u4e2a x \u548c\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u5341\u516d\u8fdb\u5236\u6570\u5b57\u7ec4\u6210\u3002<\/p>\n<p><strong>\u5b57\u7b26\u4e32\u5b57\u9762\u503c<\/strong><\/p>\n<p>\u4e4b\u524d\u89c1\u8fc7\u7684\u6240\u6709\u5b57\u9762\u503c\u90fd\u6709\u57fa\u672c\u5185\u7f6e\u7c7b\u578b\u3002\u8fd8\u6709\u4e00\u79cd\u5b57\u9762\u503c\uff08\u5b57\u7b26\u4e32\u5b57\u9762\u503c\uff09\u66f4\u52a0\u590d\u6742\u3002\u5b57\u7b26\u4e32\u5b57\u9762\u503c\u662f\u4e00\u4e32\u5e38\u91cf\u5b57\u7b26\uff0c\u8fd9\u79cd\u7c7b\u578b\u5c06\u5728\u7b2c 4.3 \u8282\u8be6\u7ec6\u8bf4\u660e\u3002<\/p>\n<p>\u5b57\u7b26\u4e32\u5b57\u9762\u503c\u5e38\u91cf\u7528\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\u7684\u96f6\u4e2a\u6216\u8005\u591a\u4e2a\u5b57\u7b26\u8868\u793a\u3002\u4e0d\u53ef\u6253\u5370\u5b57\u7b26\u8868\u793a\u6210\u76f8\u5e94\u7684\u8f6c\u4e49\u5b57\u7b26\u3002<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>\u201cHello World!\u201d \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ simple string literal<br \/>\u201c\u201d \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ empty string literal<br \/>\u201c\\nCC\\\u8f83\u597dtions\\tfile.[cC]\\n\u201d \u00a0 \/\/ string literal using newlines and tabs<\/p>\n<\/blockquote>\n<p>\u4e3a\u4e86\u517c\u5bb9 C \u8bed\u8a00\uff0cC++ \u4e2d\u6240\u6709\u7684\u5b57\u7b26\u4e32\u5b57\u9762\u503c\u90fd\u7531\u7f16\u8bd1\u5668\u81ea\u52a8\u5728\u672b\u5c3e\u6dfb\u52a0\u4e00\u4e2a\u7a7a\u5b57\u7b26\u3002\u5b57\u7b26\u5b57\u9762\u503c<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>\u2018A\u2019 \/\/ single quote: character literal<\/p>\n<\/blockquote>\n<p>\u8868\u793a\u5355\u4e2a\u5b57\u7b26 A\uff0c\u7136\u800c<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>\u201cA\u201d \/\/ double quote: character string literal<\/p>\n<\/blockquote>\n<p>\u8868\u793a\u5305\u542b\u5b57\u6bcd A \u548c\u7a7a\u5b57\u7b26\u4e24\u4e2a\u5b57\u7b26\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u6b63\u5982\u5b58\u5728\u5bbd\u5b57\u7b26\u5b57\u9762\u503c\uff0c\u5982<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>\u00a0 L\u2019a\u2019<\/p>\n<\/blockquote>\n<p>\u4e5f\u5b58\u5728\u5bbd\u5b57\u7b26\u4e32\u5b57\u9762\u503c\uff0c\u4e00\u6837\u5728\u524d\u9762\u52a0\u201cL\u201d\uff0c\u5982<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>L\u201da wide string literal\u201d<\/p>\n<\/blockquote>\n<p>\u5bbd\u5b57\u7b26\u4e32\u5b57\u9762\u503c\u662f\u4e00\u4e32\u5e38\u91cf\u5bbd\u5b57\u7b26\uff0c\u540c\u6837\u4ee5\u4e00\u4e2a\u5bbd\u7a7a\u5b57\u7b26\u7ed3\u675f\u3002<\/p>\n<p><strong>\u5b57\u7b26\u4e32\u5b57\u9762\u503c\u7684\u8fde\u63a5<\/strong><\/p>\n<p>\u4e24\u4e2a\u76f8\u90bb\u7684\u4ec5\u7531\u7a7a\u683c\u3001\u5236\u8868\u7b26\u6216\u6362\u884c\u7b26\u5206\u5f00\u7684\u5b57\u7b26\u4e32\u5b57\u9762\u503c\uff08\u6216\u5bbd\u5b57\u7b26\u4e32\u5b57\u9762\u503c\uff09\uff0c\u53ef\u8fde\u63a5\u6210\u4e00\u4e2a\u65b0\u5b57\u7b26\u4e32\u5b57\u9762\u503c\u3002\u8fd9\u4f7f\u5f97\u591a\u884c\u4e66\u5199\u957f\u5b57\u7b26\u4e32\u5b57\u9762\u503c\u53d8\u5f97\u7b80\u5355\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>\/\/ concatenated long string literal<br \/>std::cout &lt;&lt; \u201ca multi-line \u201c<br \/>\u201cstring literal \u201c<br \/>\u201cusing concatenation\u201d<br \/>&lt;&lt; std::endl;<\/p>\n<\/blockquote>\n<p>\u6267\u884c\u8fd9\u6761\u8bed\u53e5\u5c06\u4f1a\u8f93\u51fa\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>a multi-line string literal using concatenation<\/p>\n<\/blockquote>\n<p>\u5982\u679c\u8fde\u63a5\u5b57\u7b26\u4e32\u5b57\u9762\u503c\u548c\u5bbd\u5b57\u7b26\u4e32\u5b57\u9762\u503c\uff0c\u5c06\u4f1a\u51fa\u73b0\u4ec0\u4e48\u7ed3\u679c\u5462\uff1f\u4f8b\u5982\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>\/\/ Concatenating plain and wide character strings is undefined<br \/>std::cout &lt;&lt; \u201cmulti-line \u201d L\u201dliteral \u201d &lt;&lt; std::endl;<\/p>\n<\/blockquote>\n<p>\u5176\u7ed3\u679c\u662f\u672a\u5b9a\u4e49\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u8fde\u63a5\u4e0d\u540c\u7c7b\u578b\u7684\u884c\u4e3a\u6807\u51c6\u6ca1\u6709\u5b9a\u4e49\u3002\u8fd9\u4e2a\u7a0b\u5e8f\u53ef\u80fd\u4f1a\u6267\u884c\uff0c\u4e5f\u53ef\u80fd\u4f1a\u5d29\u6e83\u6216\u8005\u4ea7\u751f\u6ca1\u6709\u7528\u7684\u503c\uff0c\u800c\u4e14\u5728\u4e0d\u540c\u7684\u7f16\u8bd1\u5668\u4e0b\u7a0b\u5e8f\u7684\u52a8\u4f5c\u53ef\u80fd\u4e0d\u540c\u3002<\/p>\n<p><strong>\u591a\u884c\u5b57\u9762\u503c<\/strong><\/p>\n<p>\u5904\u7406\u957f\u5b57\u7b26\u4e32\u6709\u4e00\u4e2a\u66f4\u57fa\u672c\u7684\uff08\u4f46\u4e0d\u5e38\u4f7f\u7528\uff09\u65b9\u6cd5\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u4f9d\u8d56\u4e8e\u5f88\u5c11\u4f7f\u7528\u7684\u7a0b\u5e8f\u683c\u5f0f\u5316\u7279\u6027\uff1a\u5728\u4e00\u884c\u7684\u672b\u5c3e\u52a0\u4e00\u53cd\u659c\u7ebf\u7b26\u53f7\u53ef\u5c06\u6b64\u884c\u548c\u4e0b\u4e00\u884c\u5f53\u4f5c\u540c\u4e00\u884c\u5904\u7406\u3002<\/p>\n<p>\u6b63\u5982\u7b2c 1.4.1 \u8282\u63d0\u5230\u7684\uff0cC++ \u7684\u683c\u5f0f\u975e\u5e38\u81ea\u7531\u3002\u7279\u522b\u662f\u6709\u4e00\u4e9b\u5730\u65b9\u4e0d\u80fd\u63d2\u5165\u7a7a\u683c\uff0c\u5176\u4e2d\u4e4b\u4e00\u662f\u5728\u5355\u8bcd\u4e2d\u95f4\u3002\u7279\u522b\u662f\u4e0d\u80fd\u5728\u5355\u8bcd\u4e2d\u95f4\u65ad\u5f00\u4e00\u884c\u3002\u4f46\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u53cd\u659c\u7ebf\u7b26\u53f7\u5de7\u5999\u5b9e\u73b0\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>\/\/ ok: A \\ before a newline ignores the line break<br \/>std::cou\\<br \/>t &lt;&lt; \u201cHi\u201d &lt;&lt; st\\<br \/>d::endl;<\/p>\n<\/blockquote>\n<p>\u7b49\u4ef7\u4e8e<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>std::cout &lt;&lt; \u201cHi\u201d &lt;&lt; std::endl;<\/p>\n<\/blockquote>\n<p>\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u7279\u6027\u6765\u7f16\u5199\u957f\u5b57\u7b26\u4e32\u5b57\u9762\u503c\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>\/\/ multiline string literal<br \/>std::cout &lt;&lt; \u201ca multi-line \\<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0string literal \\<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0using a backslash\u201d<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&lt;&lt; std::endl;<br \/>return 0;<br \/>}<\/p>\n<\/blockquote>\n<p>\u6ce8\u610f\u53cd\u659c\u7ebf\u7b26\u53f7\u5fc5\u987b\u662f\u8be5\u884c\u7684\u5c3e\u5b57\u7b26\u2014\u2014\u4e0d\u5141\u8bb8\u6709\u6ce8\u91ca\u6216\u7a7a\u683c\u7b26\u3002\u540c\u6837\uff0c\u540e\u7ee7\u884c\u884c\u9996\u7684\u4efb\u4f55\u7a7a\u683c\u548c\u5236\u8868\u7b26\u90fd\u662f\u5b57\u7b26\u4e32\u5b57\u9762\u503c\u7684\u4e00\u90e8\u5206\u3002\u6b63\u56e0\u5982\u6b64\uff0c\u957f\u5b57\u7b26\u4e32\u5b57\u9762\u503c\u7684\u540e\u7ee7\u884c\u624d\u4e0d\u4f1a\u6709\u6b63\u5e38\u7684\u7f29\u8fdb\u3002<\/p>\n<p><strong>\u5efa\u8bae\uff1a\u4e0d\u8981\u4f9d\u8d56\u672a\u5b9a\u4e49\u884c\u4e3a<\/strong><\/p>\n<p>\u4f7f\u7528\u4e86\u672a\u5b9a\u4e49\u884c\u4e3a\u7684\u7a0b\u5e8f\u90fd\u662f\u9519\u8bef\u7684\uff0c\u5373\u4f7f\u7a0b\u5e8f\u80fd\u591f\u8fd0\u884c\uff0c\u4e5f\u53ea\u662f\u5de7\u5408\u3002\u672a\u5b9a\u4e49\u884c\u4e3a\u6e90\u4e8e\u7f16\u8bd1\u5668\u4e0d\u80fd\u68c0\u6d4b\u5230\u7684\u7a0b\u5e8f\u9519\u8bef\u6216\u592a\u9ebb\u70e6\u4ee5\u81f3\u65e0\u6cd5\u68c0\u6d4b\u7684\u9519\u8bef\u3002<\/p>\n<p>\u4e0d\u5e78\u7684\u662f\uff0c\u542b\u6709\u672a\u5b9a\u4e49\u884c\u4e3a\u7684\u7a0b\u5e8f\u5728\u6709\u4e9b\u73af\u5883\u6216\u7f16\u8bd1\u5668\u4e2d\u53ef\u4ee5\u6b63\u786e\u6267\u884c\uff0c\u4f46\u5e76\u4e0d\u80fd\u4fdd\u8bc1\u540c\u4e00\u7a0b\u5e8f\u5728\u4e0d\u540c\u7f16\u8bd1\u5668\u4e2d\u751a\u81f3\u5728\u5f53\u524d\u7f16\u8bd1\u5668\u7684\u540e\u7ee7\u7248\u672c\u4e2d\u4f1a\u7ee7\u7eed\u6b63\u786e\u8fd0\u884c\uff0c\u4e5f\u4e0d\u80fd\u4fdd\u8bc1\u7a0b\u5e8f\u5728\u4e00\u7ec4\u8f93\u5165\u4e0a\u53ef\u4ee5\u6b63\u786e\u8fd0\u884c\u4e14\u5728\u53e6\u4e00\u7ec4\u8f93\u5165\u4e0a\u4e5f\u80fd\u591f\u6b63\u786e\u8fd0\u884c\u3002<\/p>\n<p>\u7a0b\u5e8f\u4e0d\u5e94\u8be5\u4f9d\u8d56\u672a\u5b9a\u4e49\u884c\u4e3a\u3002\u540c\u6837\u5730\uff0c\u901a\u5e38\u7a0b\u5e8f\u4e0d\u5e94\u8be5\u4f9d\u8d56\u673a\u5668\u76f8\u5173\u7684\u884c\u4e3a\uff0c\u6bd4\u5982\u5047\u5b9a int \u7684\u4f4d\u6570\u662f\u4e2a\u56fa\u5b9a\u4e14\u5df2\u77e5\u7684\u503c\u3002\u6211\u4eec\u79f0\u8fd9\u6837\u7684\u7a0b\u5e8f\u662f\u4e0d\u53ef\u79fb\u690d\u7684\u3002\u5f53\u7a0b\u5e8f\u79fb\u690d\u5230\u53e6\u4e00\u53f0\u673a\u5668\u4e0a\u65f6\uff0c\u8981\u5bfb\u627e\u5e76\u66f4\u6539\u4efb\u4f55\u4f9d\u8d56\u673a\u5668\u76f8\u5173\u64cd\u4f5c\u7684\u4ee3\u7801\u3002\u5728\u672c\u6765\u53ef\u4ee5\u8fd0\u884c\u7684\u7a0b\u5e8f\u4e2d\u5bfb\u627e\u8fd9\u7c7b\u95ee\u9898\u662f\u4e00\u9879\u975e\u5e38\u4e0d\u6109\u5feb\u7684\u4efb\u52a1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"C++\u4e2d\u7684\u5b57\u9762\u503c\u5e38\u91cf\u662f\u6307\u5728\u7a0b\u5e8f\u4e2d\u76f4\u63a5\u4f7f\u7528\u7684\u7279\u5b9a\u503c\u3002\u8fd9\u4e9b\u5e38\u91cf\u53ef\u4ee5\u662f\u6574\u578b\u3001\u6d6e\u70b9\u578b\u3001\u5b57\u7b26\u3001\u5b57\u7b26\u4e32\u548c\u5e03\u5c14\u503c\u3002\u5b83\u4eec\u5728\u7f16\u7a0b [&hellip;]","protected":false},"author":1,"featured_media":29661,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[314],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/29659"}],"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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=29659"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/29659\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/29661"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=29659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=29659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=29659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}