⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 whitespace.msb.html

📁 this is a mirrored site c-faq. thought might need offline
💻 HTML
字号:
<html><!-- Mirrored from c-faq.com/style/whitespace.msb.html by HTTrack Website Copier/3.x [XR&CO'2008], Sat, 14 Mar 2009 08:02:16 GMT --><head><title>msb on significance of whitespace</title></head><body><p>[Someone asked about whitespace in declarations,e.g. <TT>double&nbsp;*p</TT> versus <TT>double*&nbsp;p</TT>.Mark Brader sent this email reply to the original poster,but also copied me, and gave me permission to include the reply here.]<p>From: Mark Brader<br>Subject: Re: Newbie pointer question<br>Message-ID: &lt;9509101928.AA26628@sqrex.sq.com&gt;<br>Bcc: scs@eskimo.com<p>There is no difference; it's a choice of style.  White space next toa punctuation mark is significant in C in only four cases:<ol><li><p>inside a string literal, as in <TT>" this "</TT><li><p>inside a character constant, as in <TT>' '</TT><li><p>when it serves to keep two characters from making acombination that would have another meaning, as in<pre>	x = y / *p;</pre>where you don't want to form the <TT>/*</TT> comment sign; and<li><p>after the macro name in the definition of an object-likemacro (one without an argument list) where the macrobody starts with a <TT>(</TT> character (and therefore lookslike the argument list of a function-like macro), as in<pre>	#define X (z)</pre>which defines <TT>X</TT> to expand to <TT>(z)</TT>, whereas if the spaceafter <TT>X</TT> had been omitted it would define <TT>X</TT> with oneargument and expanding to nothing.</ol><p>With the above exception, you are free to use whitespace next to allpunctuation marks, or not use it, whichever makes the program moreunderstandable to the reader.<p>Some people choose to write<p><pre>	double* p;</pre><p>because they think it's clearer that this declares <TT>p</TT> as a <TT>double&nbsp;*</TT>.However,<p><pre>	double* p, q;</pre><p>declares <TT>p</TT> as <TT>double *</TT> and <TT>q</TT> as <TT>double</TT>, <em>not</em> <TT>double&nbsp;*</TT>.  So that styleis very misleading in this case.  The alternative<p><pre>	double *p, q;</pre><p>is clearer for this declaration, and most people then use it on thefirst one<p><pre>	double *p;</pre><p>because consistency also contributes to clarity.<p>Not posted because I imagine someone else will say the same thing.Feel free to post this if you think it would make a useful contribution.<p><pre>Mark Brader             |  "It's simply a matter of style, and while theremsb@sq.com              |   are many wrong styles, there really isn't anySoftQuad Inc., Toronto  |   one right style."      -- Ray Butterworth</pre></body><!-- Mirrored from c-faq.com/style/whitespace.msb.html by HTTrack Website Copier/3.x [XR&CO'2008], Sat, 14 Mar 2009 08:02:16 GMT --></html>

⌨️ 快捷键说明

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