title: Convert a character to an integer in C++
body: <p>How can I set each character in a string to an integer? This is just the first thing I have to do in order to write a hash function. I have to set each character in a string to an integer so that I can sum their values. Please help! It it something like this??</p>
  
  <pre><code>    int hashCode(string s)
  {
     int Sum = 0;
     for(int i=0; i&lt;strlen(s); i++)
     {
        Sum += (int)s[i];
     }
     return Sum;
  }
  </code></pre>