title: C++ comparing the index of a string to another string?
body: <p>How can I compare a single character from a string, and another string (which may or may not be greater than one character)</p>
  
  <p>This program gives me almost 300 lines of random errors.  The errors don't reference a specific line number either, just a lot of stuff about "char* ", "", or "std::to_string".</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using std::cout;
  using std::string;
  
  int main() {
      string str = "MDCXIV";
      string test = "D";
  
      if (test == str[4]) {     // This line causes the problems
          cout &lt;&lt; test &lt;&lt; endl;
      }
      return 0;
  }
  </code></pre>