title: C - How to hash (create a map) of a user defined type
body: <p>I am trying to create a hash table (map/dictionary) in C on a user defined type structure. I have found many examples that use integers or strings as the key, but how would one have a user defined object as the key?</p>
  <p>The main example I have been following is <a href="https://github.com/jamesroutley/write-a-hash-table" rel="nofollow noreferrer">here</a></p>
  <p>Lets say I have different structures like:</p>
  <p>EDIT: changed the second data structure example to a better example.</p>
  <pre><code>struct Point {
    double x;
    double y;
  };
  
  struct SomePersonInfo {
    char* a_first_name;
    char* a_last_name;
    float age;
    char* address;
  };
  </code></pre>
  <p>In c++ its easy:</p>
  <pre><code>#include &lt;map&gt;
  std::map&lt; SomePersonInfo, int&gt;;
  // Maybe we want to test if some person is in our data base
  // Or assign a more complicated structure (personal info/salary/etc.) as the value
  </code></pre>
  <p>How would one hash these structs in C? Maybe a better question to ask is how to properly hash...</p>
  <p>Or maybe if anyone has any good books/tutorials/articles they know of.</p>