title: hash table for strings in c++
body: <p>i've done in the past a small exercise about hashtable but the user was giving array size and also the struct was like this (so the user was giving a number and a word each time as input)</p>
  
  <pre><code>struct data
  {
     int key;
     char c[20];
  };
  </code></pre>
  
  <p>So it was quite simple since i knew the array size and also the user was saying how many items he will be give as input. The way i did it was</p>
  
  <ul>
  <li>Hashing the keys the user gave me</li>
  <li>find the position array[hashed(key)] in the array</li>
  <li>if it was empty i would put the data there </li>
  <li>if it wasn't i would put it in the next free position i would find.</li>
  </ul>
  
  <p>But now i have to make inverted index and i am reasearching so i can make a hashtable for it. So the words will be collected from around 30 txts and they will be so many.
  So in this case how long should the array be? How can i hash words? Should i use hasing with open adressing or with chaining. The exercise sais that we could use a hash table as it is if we find it online. but i prefer to understand and create it by my own. Any clues will help me :)</p>
  
  <p>In this exerice(inverted index using hash table) the structs looks like this.
  data type is the type of the hash table i will create. </p>
  
  <pre><code>struct posting
  {
      string word;
      posting *next
  }
  
  struct data
  {
      string word;
      posting *ptrpostings;
      data *next
  };
  </code></pre>