sharp.html

来自「从www.CppReference.com打包的C++参考手册」· HTML 代码 · 共 90 行

HTML
90
字号
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>  <meta name="generator" content=  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">  <title>#, ##</title>  <link href="../cppreference.css" rel="stylesheet" type="text/css"></head><body><table>  <tr>  <td>  <div class="body-content">  <div class="header-box">    <a href="../index.html">cppreference.com</a> &gt; <a href=    "index.html">C/C++ Pre-processor Commands</a> &gt; <a href=    "sharp.html">#, ##</a>  </div>  <div class="name-format">    #, ##  </div>  <p>The # and ## operators are used with the <a href=  "define.html">#define</a> macro. Using # causes the first argument  after the # to be returned as a string in quotes. Using ##  concatenates what&#39;s before the ## with what&#39;s after it.</p>  <div class="related-examples-format">    Example code:  </div>  <div class="related-examples">    <p>For example, the command</p>    <pre class="example-code">   #define to_string( s ) # s           </pre>    <p>will make the compiler turn this command</p>    <pre class="example-code">   cout &lt;&lt; to_string( Hello World! ) &lt;&lt; endl;               </pre>    <p>into</p>    <pre class="example-code">   cout &lt;&lt; &quot;Hello World!&quot; &lt;&lt; endl;                </pre>    <p>Here is an example of the ## command:</p>    <pre class="example-code">   #define concatenate( x, y ) x ## y   ...   int xy = 10;   ...          </pre>    <p>This code will make the compiler turn</p>    <pre class="example-code">   cout &lt;&lt; concatenate( x, y ) &lt;&lt; endl;             </pre>    <p>into</p>    <pre class="example-code">   cout &lt;&lt; xy &lt;&lt; endl;              </pre>    <p>which will, of course, display &#39;10&#39; to standard    output.</p>  </div>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="define.html">#define</a>  </div>  </div>  </td>    </tr>  </table></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?