Looping vector in C++ causes invalid iterations : <p>I have written a small program that takes inputs as string which is stored in a vector. </p>

<p>Looping through the vector causes many empty strings being printed before actual output. 
I have copied the sample lines below.</p>

<pre><code>int main(){
int totalStrings;
    string inputs;
    vector&lt;string&gt; testCases(totalStrings);
    cin&gt;&gt;totalStrings;
    while(cin&gt;&gt;inputs)
        testCases.push_back(inputs);
    for(vector&lt;string&gt;::iterator it=testCases.begin();it!=testCases.end();++it)
    printCustom(*it);
    return 0;
}
</code></pre>

<p>I tried printing the size of the string in the printCustom function. I had hundreds of zero printed before the actual input </p>
