title: Binary search on C++ string does not work
body: <p>What is wrong with the following code? How come it does not found the letter using my implementation of a binary search?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;algorithm&gt;
  #include &lt;cctype&gt;
  #include &lt;cwctype&gt;
  using namespace std;
  
  bool contains(string s, char a){
    int m = 0;
    int n = s.length()-1;
  
    while (m != n) {
      int k = (m + n) / 2;
      if (s[k] == a)
        return true;
  
      if (s[k] &lt; a) {
        n = k - 1;
      } else {
        m=k + 1;
      }
    }
  
    return false;
  }
  
  int main() {
  
    string s = "miyvarxarmaiko";
    char a = 'm';
    if (contains(s,a) == true) {
      cout &lt;&lt; "s contains  character a" &lt;&lt; endl;
    } else {
      cout &lt;&lt; "does not contain" &lt;&lt; endl;
    }
  
    return 0;
  }
  </code></pre>