c++ unorderd_map got me seg fault
<pre><code>#include &lt;unordered_map&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &lt;utility&gt;
#include &lt;algorithm&gt;
using namespace std;


unordered_map &lt;string, int&gt; setupDictionary(vector&lt;string&gt; book)
{
    unordered_map&lt;string, int&gt; table;
    for (int i =0;i&lt; book.size(); i++)
    {
        string word = book[i];
        if(word != "")
        {
            if (table.find(word)==table.end())
            {
                std::pair&lt;std::string,int&gt; myshopping (word,0);
                table.insert(myshopping);
            }else
            {
                int num = table[word];
                 std::pair&lt;std::string,int&gt; myshopping (word,num+1);
                table.insert(myshopping );
            }

        }
    }
    return table;
}

int main()
{
    vector&lt;string&gt; book;
    book[1] = "hello";
    book[2] = "world";
    book[3] = "hello";
    book[4] = "world2";
    unordered_map &lt; string, int&gt; dict= setupDictionary(book);
   // printf("%s,%d",dict["hello"]);
}
</code></pre>

<p>Compile and build is good.
But after I run it, I got segmentation fault.
Need help
Dont really know whats wrong in my code.
Thank you indeed!</p>
