?? whitespace.msb.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 *p</TT> versus <TT>double* 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: <9509101928.AA26628@sqrex.sq.com><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 *</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 *</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 + -