Reading and recording character ASCII values to vector : <p>I'm attempting to open a text file, read the the file character by character, and store the ascii value of each character to a vector.</p>

<p>I am successful in opening and reading the file, but I am confused as to why the integer values are not being stored in my vector. All the values are being stored as 0s. </p>

<p>Sounds silly, but I wasn't sure if casting the char c to an integer was the issue, so I stored the (int) c value to a variable i before inputting it into the vector. The problem is, I know i is storing the ASCII values as intended, but I couldn't figure out why these values weren't being transferred to the vector. </p>

<pre><code>    char c;
    std::vector&lt;int&gt; ascii;

    while( inFile.get(c) )
    {
        std::cout &lt;&lt; c;
        ascii.push_back( (int) c );
    }

    inFile.close();
    std::cout &lt;&lt; std::endl;

    for(auto&amp; i : ascii)
    {
        std::cout &lt;&lt; ascii[i] &lt;&lt; " ";
    }
</code></pre>

<p>odoylerules</p>

<p>0 0 0 0 0 0 0 0 0 0 0 </p>
