C++: Checking for non-numeric input and assigning to a double
<p>Here is the code I have at the moment: </p>

<pre><code>char ch;
int sum = 0;
double values[10];
int i = 0;
cin &gt;&gt; ch;
    while (!isalpha(ch))
    {  
        values[i] = ch; 
        sum += values[i]; 
        i++;  
        cin &gt;&gt; ch;
    }
</code></pre>

<p>What is happening is that if I enter the value 1, that gets assigned to ch as a char.  Now ch is assigning it's value to a double and doing an implicit cast.  So it is assigning the ASCII value of '1' to values[i].  I want it to just assign 1 to values[i].  Is there a better way to do this?  Or is there something that I'm missing?</p>
