{"id":530,"date":"2018-10-23T09:31:15","date_gmt":"2018-10-23T01:31:15","guid":{"rendered":"http:\/\/www.tastestars.com\/?p=530"},"modified":"2018-10-23T09:42:03","modified_gmt":"2018-10-23T01:42:03","slug":"01-5","status":"publish","type":"post","link":"https:\/\/tastestars.com\/index.php\/2018\/10\/23\/01-5\/","title":{"rendered":"\u3010C++\u3011CONST CHAR*\u7c7b\u578b\u7684\u503c\u4e0d\u80fd\u7528\u4e8e\u521d\u59cb\u5316CHAR*\u7c7b\u578b\u7684\u5b9e\u4f53"},"content":{"rendered":"<p>\u7f16\u7a0b\u7684\u65f6\u5019\u5199\u5230\u8bed\u53e5\uff1a<\/p>\n<pre class=\"lang:c++ decode:true \" >char *pch2 = \"string\"<\/pre>\n<p>\u7684\u65f6\u5019\u9047\u5230\u62a5\u9519\uff0c\u201cCONST CHAR<em>\u7c7b\u578b\u7684\u503c\u4e0d\u80fd\u7528\u4e8e\u521d\u59cb\u5316CHAR<\/em>\u7c7b\u578b\u7684\u5b9e\u4f53\u201d\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"531\" data-permalink=\"https:\/\/tastestars.com\/index.php\/2018\/10\/23\/01-5\/%e6%8d%95%e8%8e%b7-9\/\" data-orig-file=\"https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/\u6355\u83b7.png\" data-orig-size=\"311,98\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"\u6355\u83b7\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/\u6355\u83b7-300x95.png\" data-large-file=\"https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/\u6355\u83b7.png\" src=\"http:\/\/www.tastestars.com\/wp-content\/uploads\/2018\/10\/\u6355\u83b7.png\" alt=\"\" width=\"311\" height=\"98\" class=\"aligncenter size-full wp-image-531\" srcset=\"https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/\u6355\u83b7.png 311w, https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/\u6355\u83b7-300x95.png 300w\" sizes=\"auto, (max-width: 311px) 100vw, 311px\" \/><br \/>\n\u6709\u4eba\u8bf4\u662f\u56e0\u4e3a\u4e4b\u524d\u7684vs\u7248\u672c\u53ef\u4ee5\u5199\u6210char*\u662f\u5386\u53f2\u9057\u7559\u539f\u56e0\uff0c\u5728vs2017\u4e2d\uff0c\u7a0b\u5e8f\u53ef\u80fd\u5c31\u5d29\u6e83\u4e86\uff0c\u65b0\u7248\u672cVS\u5bf9\u8fd9\u4e2a\u8fdb\u884c\u4e86\u66f4\u4e25\u683c\u7684\u63a7\u4ef6\u3002<\/p>\n<p>\u53ef\u4ee5\u5148\u7528\u5b57\u7b26\u6570\u7ec4\u5b58\u50a8\uff0c\u518d\u7ed9\u6307\u9488\u7528\u4e86<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"532\" data-permalink=\"https:\/\/tastestars.com\/index.php\/2018\/10\/23\/01-5\/%e6%8d%95%e8%8e%b72-3\/\" data-orig-file=\"https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/\u6355\u83b72.png\" data-orig-size=\"336,197\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"\u6355\u83b72\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/\u6355\u83b72-300x176.png\" data-large-file=\"https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/\u6355\u83b72.png\" src=\"http:\/\/www.tastestars.com\/wp-content\/uploads\/2018\/10\/\u6355\u83b72.png\" alt=\"\" width=\"336\" height=\"197\" class=\"aligncenter size-full wp-image-532\" srcset=\"https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/\u6355\u83b72.png 336w, https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/\u6355\u83b72-300x176.png 300w\" sizes=\"auto, (max-width: 336px) 100vw, 336px\" \/><\/p>\n<p>\u989d\u90a3\u987a\u4fbf\u628a\u4ee3\u7801\u9644\u4e0a\uff0c<br \/>\n\u603b\u662f\u5f04\u4e0d\u6307\u9488\u6570\u7ec4\u53d6\u5730\u5740\uff0c\u4eca\u5929\u65e9\u4e0a\u65e9\u8d77\u505a\u4e86\u4e2a\u5c0f\u5c0f\u7ec3\u4e60\uff1a<\/p>\n<pre class=\"lang:c++ decode:true \" >#include &lt;iostream&gt;\nusing namespace std;\nvoid testCharArray() {\n    char ch1[12] = \"Hello,world\";\n    char test[] = \"string\";\n    char *pch1, *pch2 = test;\n    char *pch3, *pch4;\n    pch3 = &amp;ch1[2];\n    char ch = 'c';\n    pch4 = &amp;ch;\n    pch1 = ch1;\n    cout &lt;&lt; pch1 &lt;&lt; endl;    \/\/\u8f93\u51fa ch1[0]\u5230\\0 \u4e4b\u524d\u7684\u6240\u6709\u5b57\u7b26\n    cout &lt;&lt; pch2 &lt;&lt; endl;    \/\/\u8f93\u51fa ch1[0]\u5230\\0 \u4e4b\u524d\u7684\u6240\u6709\u5b57\u7b26\n    cout &lt;&lt; pch3 &lt;&lt; endl;    \/\/\u8f93\u51fa ch1[2]\u5230\\0 \u4e4b\u524d\u7684\u6240\u6709\u5b57\u7b26\n    cout &lt;&lt; *pch3 &lt;&lt; endl;    \/\/\u89e3\u5f15\u7528 pch3 \u8f93\u51fa pch3 \u6307\u5411\u7684\u5b57\u7b26\n    cout &lt;&lt; *pch4 &lt;&lt; endl;    \/\/\u89e3\u5f15\u7528 pch4 \u8f93\u51fa pch4 \u6307\u5411\u7684\u5b57\u7b26\n}\n\nint main() {\n    testCharArray();\n    getchar();\n    return 0;\n}<\/pre>\n<p>\u7ed3\u679c\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"535\" data-permalink=\"https:\/\/tastestars.com\/index.php\/2018\/10\/23\/01-5\/attachment\/123\/\" data-orig-file=\"https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/123.png\" data-orig-size=\"517,279\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"123\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/123-300x162.png\" data-large-file=\"https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/123.png\" src=\"http:\/\/www.tastestars.com\/wp-content\/uploads\/2018\/10\/123.png\" alt=\"\" width=\"517\" height=\"279\" class=\"aligncenter size-full wp-image-535\" srcset=\"https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/123.png 517w, https:\/\/tastestars.com\/wp-content\/uploads\/2018\/10\/123-300x162.png 300w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7f16\u7a0b\u7684\u65f6\u5019\u5199\u5230\u8bed\u53e5\uff1a char *pch2 = &#8220;string&#8221; \u7684\u65f6\u5019\u9047\u5230\u62a5\u9519\uff0c\u201cCONST CHAR\u7c7b\u578b\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[32],"tags":[],"class_list":["post-530","post","type-post","status-publish","format-standard","hentry","category-c"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9Hs6X-8y","_links":{"self":[{"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/posts\/530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/comments?post=530"}],"version-history":[{"count":3,"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/posts\/530\/revisions"}],"predecessor-version":[{"id":536,"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/posts\/530\/revisions\/536"}],"wp:attachment":[{"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/media?parent=530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/categories?post=530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tastestars.com\/index.php\/wp-json\/wp\/v2\/tags?post=530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}