C++ cin.get before a loop
<p>hey guys, i'm designing a C++ program that reads a sequence of one or more positive real numbers terminated by a negative number. To test that this has been done correctly i'm outputting the 5th number entered by the user. i am using a while loop to populate my array HOWEVER, my <code>cin.get(x)</code> is making my program not compile. please help my fix my code.</p>

<p>P.S this is the compliers error(s) if it is any help:  </p>

<blockquote>
  <p>solution1.cpp: In function <code>‘int main()’</code>:
  <br />solution1.cpp:19: error: no matching function for call to <code>‘std::basic_istream&lt;char, std::char_traits&lt;char&gt; &gt;::get(int&amp;)’</code></p>
  
  <p>/usr/include/c++/4.4/istream:280:
  <br />note: candidates are: <code>typename std::basic_istream&lt;_CharT, _Traits&gt;::int_type std::basic_istream&lt;_CharT, _Traits&gt;::get() [with _CharT = char, _Traits = std::char_traits&lt;char&gt;]</code></p>
  
  <p>/usr/include/c++/4.4/istream:294:
  <br />note: <code>std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::basic_istream&lt;_CharT, _Traits&gt;::get(_CharT&amp;) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;]</code></p>
  
  <p>/usr/include/c++/4.4/istream:321:
  <br />note: <code>std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::basic_istream&lt;_CharT, _Traits&gt;::get(_CharT*, std::streamsize, _CharT) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;]</code></p>
  
  <p>/usr/include/c++/4.4/istream:332:
  <br />note: <code>std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::basic_istream&lt;_CharT, _Traits&gt;::get(_CharT*, std::streamsize) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;]</code></p>
  
  <p>/usr/include/c++/4.4/istream:355:
  <br />note: <code>std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::basic_istream&lt;_CharT, _Traits&gt;::get(std::basic_streambuf&lt;_CharT, _Traits&gt;&amp;, _CharT) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;]</code></p>
  
  <p>/usr/include/c++/4.4/istream:365:
  <br />note: <code>std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::basic_istream&lt;_CharT, _Traits&gt;::get(std::basic_streambuf&lt;_CharT, _Traits&gt;&amp;) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;]</code></p>
</blockquote>

<pre><code>#include &lt;iostream&gt; 
using namespace std; 

int main() 
{
    char num[100] = {0};
    int y = 0;
    int x = 0;
    int flag = 0;

    cout &lt;&lt; "Please enter line of numbers: ";

    while (flag &gt; 0)
    {
        cin.get(x);

        if (x &lt; 0)
        {
            flag = -1;
        }
        else
        {
            num[y] = x;
            y = y + 1;
        }
    }

    cout &lt;&lt; "           " &lt;&lt; num[4] &lt;&lt; endl;

    return 0;
}
</code></pre>
