    <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  :: Members' Experiences</title>
        <link>https://members.accu.org/index.php/articles/1151</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 14, #1 - Feb 2002</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/c116/">141</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;Members' Experiences</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 03 February 2002 13:15:49 +00:00 or Sun, 03 February 2002 13:15:49 +00:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e27" id="d0e27"></a></h2>
</div>
<p>Dear Editor,</p>
<p>I have the following comments related to Members' Experiences
reported by Francis in the last issue of C Vu.</p>
<div class="orderedlist">
<ol type="1">
<li>
<p>We have recently released Ch version 2.1. Ch Standard Edition is
now free for unlimited use by students, instructors, and employees
of non-profit organizations.</p>
<p>Ch is a C interpreter with C++ classes. Ch 2.1 supports C90 and
many new features such as complex numbers, variable length arrays
(VLA), IEEE floating-point arithmetic, generic functions in C99, as
well as industry standards POSIX, X11/Motif, OpenGL, ODBC, GTK+. Ch
2.1 for Windows has extensive collections of Unix utilities
including vi, ls, awk, sed, grep, cp, find, etc. It is quite
effective for cross platform shell programming in C.</p>
</li>
<li>
<p>For passing arrays of different starting index and length to a
function, the upper bound of the array can be omitted. That is, the
function prototype <tt class="literal">void printout(int
primes[0:upper]);</tt> can be changed to <tt class="literal">void
printout(int primes[0:]);</tt> so that arrays with different upper
and lower bounds can be passed to the function. The number of
elements of the array passed can be obtained by the generic
function <tt class="function">shape()</tt> which returns a
computational array with the shape of the passed array. Using this
scheme, Francis' prime number generating program can be re-written
as follows:</p>
<pre class="programlisting">
#include &lt;iostream.h&gt;
#define upper 1000000
void printout(int primes[0:]){
  int newline = 0;
  int i;
  int num;
  num = (int)shape(primes);
  for(i=0; i&lt;num; i++){
    if(primes[i]){
      newline++;
      if(newline&gt;10){
        cout &lt;&lt; &quot;\n&quot;;
        newline=0;
      }
      cout &lt;&lt; primes[i] &lt;&lt;' ';
    }
  }
  cout &lt;&lt; primes[num]; 
// warning for array out of bounds
  cout &lt;&lt; primes[num+1];    
// warning for array out of bounds
}
int main(){
  int primes[1:upper];
  int i=0;
  for(i=1; i&lt;=upper; i++){
    primes[i] = i*2-1;
  }
  primes[1] = 0;
  int mark=3;
  do{
    for(i=mark*mark/2+1; i&lt;=upper; i+=mark){
      primes[i]=0;
    }
    for(i=(mark+1)/2 + 1; i&lt;=upper; i++){
      if(primes[i]){
        mark=primes[i];
        break;
      }
    }
  }while(mark*mark&lt;upper);
  printout(primes);
  return 0;
}
</pre>
<p>Using the above defined function <tt class=
"function">printout()</tt>, arrays with different length and bounds
can be passed to it as shown below without a warning message at the
parsing stage.</p>
<pre class="programlisting">
#define upper 1000000
int main() {
  int primes1[1:upper];
  int primes2[0:upper+1];
/* ... */
  printout(primes1);
  printout(primes2);
/* ... */
}
</pre></li>
<li>
<p>The <tt class="literal">foreach</tt>-loop in Ch can be iterated
in following three forms:</p>
<pre class="programlisting">
foreach(token; expr1; expr2; expr3) 
  statement
foreach(token; expr1; expr2) 
  statement
foreach(token; expr1) 
  statement
</pre>
<p>Arguments token, expr1, expr2 and expr3 can be of either string
type or pointer to char. For example, the following code</p>
<pre class="programlisting">
  char *s;
  foreach(s;&quot;123 456 789&quot;){
    printf(&quot;s = %s\n&quot;, s); 
  }
  char *cond=NULL;
  char *delimit = &quot;: &quot;;
  foreach(s;&quot;abc:def ABC&quot;; cond; delimit){
    printf(&quot;s = %s\n&quot;, s); 
  }
  /* output:
     s = 123
     s = 456 
     s = 789
     s = adb
     s = def
     s = ABC
  */
</pre>
<p>is valid in Ch.</p>
</li>
</ol>
</div>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
