title: How to compare a string in a C program
body: <p>I have a question about how to compare strings in an <code>if</code> statement. I am moving from Python to C and the comparing strings is easy in Python, but in C how do I do it?</p>
  
  <p>My program is:</p>
  
  <pre><code>printf("Enter your choice 1.add\n 2.sub\n 3.mul\n 4.div\n");
  string choice = get_string();
  
  if (choice == "add")
  {
      int c = calculate_add(a, b);
      printf("sum of %i and %i is %i\n", a, b, c);
  }
  </code></pre>
  
  <p>When I run this, I get this error:</p>
  
  <pre><code>calculate.c:19:16: error: result of comparison against a string literal is
    unspecified (use strncmp instead) [-Werror,-Wstring-compare]
  if (choice == "add")
             ^  ~~~~~
  </code></pre>
  
  <p>It says use <code>strncmp</code> to compare the string, but how do I do it?</p>