Understanding special type of access C++/C array : <p>I have the following code snippet:</p>

<pre><code>int ndigit[10] = {0,0,0,0,0,0,0,0,0,0};

void count() {
    char c;
    while (cin.get(c)) {
    if (c&gt;='0' &amp;&amp; c&lt;='9') {
        ndigit[c-'0']++;
    }
}
</code></pre>

<p>So <code>c</code> has to be between 0 and 9 (with 0 and 9), so why it is necessary to index the array like <code>ndigit[c-'0']</code> instead of just <code>ndigit[c]</code> ?</p>

<p>If I am right, in both cases a <code>c</code> value can occur more then once, so a the value of <code>ndigit[c-'0']</code> gets overwritten anyway...</p>

<p>I appreciate your wisdom!</p>
