<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
  <title>Linux Format forums</title>
  <link>http://linuxformat.com/forums/index.php</link>
  <description>Help, discussion, magazine feedback and more</description>
  <language>english</language>
  <copyright>(c) Copyright Wed Jun 19, 2013 7:33 pm by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Wed Jun 19, 2013 7:33 pm</pubDate>
  <lastBuildDate>Wed Jun 19, 2013 7:33 pm</lastBuildDate>
  <docs>http://backend.userland.com/rss</docs>
  <generator>phpBB2 RSS Syndication Mod by Lucas</generator>
  <ttl>1</ttl>

  <image>
    <title>Linux Format forums</title>
    <url></url>
    <link>http://linuxformat.com/forums/</link>
    <description>Help, discussion, magazine feedback and more</description>
  </image>

                                      <item>
                                        <title>C++ quirks (or likely my own stupity). (Solved)</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=18456#18456</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=5530'&gt;GMorgan&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Sat Mar 04, 2006 11:18 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      I've had trouble with entering a value into a 20 character array using the &lt;br /&gt;
cin.get command with three arguments. The problem that occurs is  if somebody simply presses enter with no value entered the program seemingly goes into an infinite loop rather than entering the '\0' character into the 0 element of the array. The code I've been using for entry is below&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;&amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; &amp;quot;Second line&amp;#58;&amp;quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;cin.get&amp;#40;incr-&amp;gt;secondadd, 20, '\n'&amp;#41;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;cin.ignore&amp;#40;255,'\n'&amp;#41;;&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
The cin.ignore is there incase somebody enters more than 19 characters into the array. It works in Dev-Cpp (which uses a GNU compiler, I thought they'd have the same quirks even across platforms ) in windows but on trying to run it in Ubuntu I get the problem above. The cin.getline command solves the one problem (that being entering '\0' on an empty entry) but leaves me with an infinite loop even with the cin.ignore command if more than 19 characters are entered (the cin.ignore also requires a enter each time since getline flushes the '\n' character from the buffer).&lt;br /&gt;
&lt;br /&gt;
If anyone has a solution that enters '\0' into secondadd[0] on an empty entry while also truncating the entry should it exceed 19 characters I will be grateful. The '\0' is necessary since I use it later to skip an empty field during output.&lt;br /&gt;
&lt;br /&gt;
//edit - nevermind I found a solution //</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=18456#18456</comments>
                                        <author>GMorgan</author>
                                        <pubDate>Sat Mar 04, 2006 11:18 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=18456#18456</guid>
                                      </item></channel></rss>