    <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' Letters</title>
        <link>https://members.accu.org/index.php/articles/1358</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">Letters to the Editor + Overload Journal #2 - Jun 1993</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/c184/">Journal Columns</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c186/">LettersEditor</a>
<br />

                                            <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/c78/">Overload</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c222/">02</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/c186-222/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/articles/c186+222/">All of these categories</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' Letters</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 30 June 1993 11:53:00 +01:00 or Wed, 30 June 1993 11:53:00 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<p>Mike,</p>
<p>I know it helps to get feedback, so here is some regarding the first
issue of Overload. I think the content is first rate. As an experienced
C programmer, but C++ novice, I found all the articles interesting,
useful and well written. I would be happy with more of the same. On the
production side, I would like to see more consistent use of fonts.
Also, I personally don't like the use of 'script' type fonts in
magazines (other than, say, as signatures). Finally, I would prefer to
have all the book reviews together in one place. Not, I hasten to add,
just because they are in CVu like that. I do genuinely find it
preferable.</p>
<p>In summary, an excellent first issue, but a few changes to cater for
my own personal prejudices! Well done. <br>
Regards - Ian Cargill</p>
<p style="font-style: italic;">Thanks Ian. Many others who have seen
Overload took a dislike to the numerous fonts. I hope you like the new
look. Subject matter has now been grouped as much as possible, I hope
you like it. Mike Toms</p>
<p>Mike,</p>
<p>Thank you very much indeed for your very interesting first
issue of Overload. You asked for letters! The following question on C++
Streams immediately springs to mind, as
an idea for inclusion into a future issue. Do you know if there
is a &quot;Streams&quot; substitute for getch() and bioskey()?</p>
<p>If you want to read a character without echo, or to get all entered
keys in full character code and scancode form as in a line editor, it
would be nice to just use the iostream
library, instead of having to pull in the CONIO or BIOS library modules
just for these functions.</p>
<p>The very best of luck to Overload. <br>
Yours Sincerely - Peter Wippell</p>
<p style="font-style: italic;">To the best of my knowledge there is no
such stream function. It is possible to produce one by making a
custom streambuf to access the keyboard buffer directly. To
accomplish this there are a number of problems to overcome, but I'll
look into it for a future article. In the meantime, don't be too upset
to bring getch() or bioskey() into your programs. Bioskey is a very
small function and will only increase the program size by approximately
70 bytes.</p>
<p>Mike,</p>
<p>Congratulations to you and your colleagues on the first edition of
Overload. If it continues the way it has started out it will be one of
the best value for money magazines around. I found it very interesting
and useful, and the larger format makes it easier reading than CVu,
especially the code. In case Francis is reading (and he almost
certainly is), I still love CVu. I feel sorry for CUG(UK) members who
have not joined the Turbo C++ SIG, because the majority of articles are
not Borland specific, but are good, solid standard C++. Since becoming
a member of CUG(UK), I have always tried to program in standard C or
C++ as this is the line pushed there; quite correctly I believe.
Portability is important and careful thought must be given to using
special features.</p>
<p>The article on streams looks like being very helpful. Despite
studying several books there is still much I don't understand. For
example, I wanted a program which would run a loop reading in a string
and a value, and print them out. In simplified form it looks like this:</p>
<pre class="programlisting">#include &lt;iostream.h&gt; main()<br>{<br>  charbuf[100]; <br>  double value; <br>  do<br>  {<br>    cin.get(buf,100); // cin &gt;&gt; doesn't work with spaces<br>    cin &gt;&gt; value;<br>    cout &lt;&lt; buf &lt;&lt; &quot;     &quot; &lt;&lt; value &lt;&lt; endl &lt;&lt; endl; <br>  } while (value != 0); <br>  return 0; <br>}</pre>
<p>The program goes into uncontrolled looping the second time round the
loop. Perhaps you or another reader can help.</p>
<p>By way of a contribution, I have a rough and ready boolean class
which I have used. I will try and polish it up and send it in.</p>
<p>Wishing you continued good fortune with the magazine. <br>
Yours Sincerely - Jim Bartholomew <br>
</p>
<p><span style="font-style: italic;">I hope we can continue to please
you Jim. I agree with your views on writing standard code, however, in
order to exploit products such as OWL and Turbo Vision, non-standard
code must be used.</span></p>
<p style="font-style: italic;">The problem with your program is that
the cin &gt;&gt; double whilst extracting the characters of the double
number it leaves the carriage-return in the stream. If you add the line
char scrap at the start and perform a cin.get(scrap) after the extract
your double will find that the CR is removed. This should cure your
looping. P.S. You should also test the return status of the stream
after input (see this issues streams article). Mike</p>
<p>Mike,</p>
<p>RE: Overload Issue 1 - Article on Streams.</p>
<p>Streams seem to be a really useful feature of C++ and its a great
pity that they are grossly underused. Your series of articles will do a
great job in helping to put that right. If I may, I
would like to add a little to the discussion on
strstream in the first article.</p>
<p>First, under Problems with 'ostream', to get rid of a frozen string
when you have finished with it, all you have to do is delete it. So the
final lines of the example under automatic memory allocation might be
amended to read:-</p>
<pre class="programlisting">char *frozen = buffer.str(); // freeze the string<br>cout &lt;&lt; frozen;              // output to the console<br>delete [] frozen;            // remove it from the heap</pre>
<p>Used this way, ostream becomes an extremely useful replacement for
both scanf() and malloc() with much improved formatting facilities.</p>
<p>Second, from under From-Memory reading, in the example, the removal
of whitespace and the use of the 'get' member function is not
necessary. The same output is obtained by erasing those lines and
adding &quot; &gt;&gt; s1 &gt;&gt; s2; &quot; to the main stringstream output
line. The example below shows how you can read a string of several
words separated by whitespace, if it is the final string in the buffer
or there is a convenient terminator. Otherwise you would have to read
word by word as in the article.</p>
<pre class="programlisting">// From-Memory reading amended to read<br>// the final string<br>#include &lt;strstream.h&gt;<br><br>int main()<br>{<br>  char memory_info[] = &quot;100 200 22.995    hello fred&quot;;<br>  int i1, i2;<br>  float f1;<br>  char s[20];<br>  istrstream stringstream(memory_info,<br>  sizeof(memory_info)); <br>  stringstream &gt;&gt; i1 &gt;&gt; i2 &gt;&gt; f1; <br>  // stringstream &gt;&gt; ws; // to remove whitespace<br>                         // if required<br>  stringstream.get(s, 20, '\0'); <br>  cout &lt;&lt; i1 &lt;&lt; endl <br>       &lt;&lt; i2 &lt;&lt; endl <br>       &lt;&lt; f1 &lt;&lt; endl <br>       &lt;&lt; s  &lt;&lt; endl; <br>  cin.peek(); // nearest I can get to getch() but you have<br>              // to hit return return 0; <br>}</pre>
<p>Good Luck to Overload <br>
- Peter Wippel (again)</p>
<p style="font-style: italic;">The delete [] freeze certainly works. I
am paranoid about identifying the matching pairs of new/delete
operators. How would I cope with missing new statements? It is not too
difficult to use:-</p>
<pre class="programlisting">buffer.rdbuf()-&gt;freeze(0);</pre>
<p style="font-style: italic;">The initial streams articles are only
intended to give a brief overview. More detail to follow! - Mike.</p></p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
