    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: Questions and Answers</title>
        <link>https://members.accu.org/index.php/articles/1062</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>




<div class="xar-mod-head"><span class="xar-mod-title">CVu Journal Vol 12, #5 - Sep 2000</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c124/">125</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;Questions and Answers</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 07 September 2000 13:15:40 +01:00 or Thu, 07 September 2000 13:15:40 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e20" id="d0e20"></a></h2>
</div>
<p>One of the purposes of this column is for the readers to supply
the answers. That is why it is in the Dialogue section.
Unfortunately, hopefully, only because of the delay in distribution
of the previous issue, no one has provided any answers. Of course,
I could sit down and write some, or appeal to one of the regular
writers to do so. As you can see, I did not do so.</p>
<p>Here is another batch of questions. Your answers to these, or to
those previously published will be most welcome. preferably before
1st November.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e26" id="d0e26"></a>Questions 1 -
4</h2>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e29" id="d0e29"></a>Jun Woong
<tt class="email">&lt;<a href=
"mailto:mycoboco@hanmail.net">mycoboco@hanmail.net</a>&gt;</tt></h3>
</div>
<p>These are questions about C.</p>
<div class="orderedlist">
<ol type="1">
<li>
<p>If the declaration of an identifier for an object has file scope
and no storage-class specifier, its linkage is external. (The
K&amp;R says just that such a declaration is tentative
definition.)</p>
</li>
<li>
<p>The declaration of an identifier for a function that has block
scope shall have no explicit storage-class specifier other than
<tt class="literal">extern</tt>'</p>
<p>However, I cannot find that rule in K&amp;R 2<sup>nd</sup>
edition. Is it not mentioned there?</p>
</li>
<li>
<p>Why does the standard disallow storage-class specifiers other
than extern on a function declaration inside a block?</p>
</li>
<li>
<p>Regarding arguments that are subject to macro expansion, on
<tt class="literal">#pragma</tt> and <tt class=
"literal">#error</tt></p>
<p>In &quot;<i class="citetitle">C:A Reference Manual (H&amp;S)</i>&quot;, it
says that:</p>
<div class="blockquote">
<blockquote class="blockquote">
<p>&quot;The argument to <tt class="literal">#pragma</tt> is subject to
macro expansion.</p>
<p>&quot;The <tt class="literal">#error</tt> directive produces a
compile-time error message that will include the argument tokens,
which are subject to macro expansion.&quot;</p>
</blockquote>
</div>
<p>Please give me examples about these. I would like to know how
the <tt class="literal">#error</tt> directive can have arguments
subject to macro expansion.)</p>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e83" id="d0e83"></a>Question 5
&amp; Tentative Answer</h2>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e86" id="d0e86"></a>Dave Midgley
<tt class="email">&lt;<a href=
"mailto:dave.midgley@uk.york.com">dave.midgley@uk.york.com</a>&gt;</tt></h3>
</div>
<p>Here is a question which looks straightforward, but three out of
three experienced C/C++ programmers in my office (one of which was
me) got it wrong:</p>
<pre class="programlisting">
int x = 10;
for (int y=0, x=0; y &lt; 2; x++; y++) { }
</pre>
<p>What is the value of x following exit from the for-loop? When
you have answered that, compare the following:</p>
<pre class="programlisting">
int x = 10;
int y;
for (y=0, x=0; y &lt; 2; x++; y++) { }
</pre>
<p>Answer is 10 in the first case, because the x in the for loop is
a new declaration and is out of scope outside the for-loop. In the
second case it is 2, (as we wrongly expected for case 1 as
well)</p>
<p>I assume this is correct compiler behaviour, but it is somewhat
unexpected. Any comment from the experts? (Compiler is Borland CPP
Builder 4)</p>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e103" id="d0e103"></a>Question
6</h2>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e106" id="d0e106"></a>from a
novice</h3>
</div>
<p>I need to open files that have statistical data in columnar
format such as:</p>
<div class="literallayout">
<p>~~~~~~<br>
10 55<br>
20 79<br>
30 50<br>
40 12<br>
~~~~~~</p>
</div>
<p>I have a way to read two columns with:</p>
<pre class="programlisting">
fscanf(fp,&quot;%d %d&quot;,xValue,yValue);
</pre>
<p>However, I need to be able to input from files with various
numbers of columns (3,4,5...n, etc.) And store each extra column
into a different array. It is quite obvious what will happen if you
give the previous function a 3-column file so I thought maybe there
is a way to analyse the first string of the file with <tt class=
"function">fscanf()</tt> until it comes to a newline, then return
the number of values counted. So I messed around with that idea all
day long and have still come up short. Is there a library function
for stuff like this or do I just not know enough about <tt class=
"function">fscanf()</tt> to be able to do it?</p>
</div>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
