Creating variables / vectors based on runtime
<p>I am working on a program that "encodes" a file based on a supplied bookfile. The resulting file has each letter replaced with a number. This number corresponds to the offset of that letters appearence in the bookfile. So if we had "hello" it would pick an 'h' from the bookfile, find its location number and replace it in the output.</p>

<p>Mine works correctly but i am looking for a way to optimize it. As of right now, everytime it brings in a new letter it creates a vector of offset numbers to choose from. I would like to be able to "save" this vector and use it again if i find the same number again.</p>

<p>I am at a loss as to how i would program this however. For example, if i read in an 'h' i would like to save it as <code>vector&lt;int&gt; hLocations</code>;</p>

<p>Is there anyway of doing this or am i just insane? i was thinking of making a function that does this, but the part that confuses me is <code>&lt;int&gt;Locations</code>;
Is there a way of using variables inside C++ code? i think that is what i am really asking.</p>
