title: C++ comparing a char to a string literal
body: <p>Beginning programmer here...</p>
  
  <p>I'm writing a very simply program for my computer science class and I ran into an issue that I'd like to know more about. Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main(int argc, const char * argv[])
  {
      char courseLevel;
  
      cout &lt;&lt; "Will you be taking graduate or undergraduate level courses (enter 'U'"
              " for undergraduate,'G' for graduate.";
      cin &gt;&gt; courseLevel;
  
      if (courseLevel == "U")
      {
          cout &lt;&lt; "You selected undergraduate level courses.";
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I'm getting two error messages for my if statement:
  1) Result of comparison against a string literal is unspecified (use strncmp instead).
  2) Comparison between pointer and integer ('int' and 'const char*').</p>
  
  <p>I seem to have resolved the issue by enclosing my U in single quotes, or the program at least works anyway. But, as I stated, I'd simply like to understand why I was getting the error so I can get a better understanding of what I'm doing.</p>