title: Compare part of an input string using strcmp() in C
body: <p>Normally strcmp is used with two arguments [e.g. strcmp(str1,"garden")], and it will return 0 if both are the same.</p>
  
  <p>Is it possible to compare part of the input, say the first five character of the input? (for example, <code>strcmp(str1,"garde",5)</code>)</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include&lt;string.h&gt;
  
  int main(void) {
  
      char str1[] = "garden";
  
      if (strcmp(str1, "garden") == 0)
      {
          printf("1");
      }
      if (strcmp(str1, "garden", 6) == 0)
      {
          printf("2");
      }
      if (strcmp(str1, "garde", 5) == 0)
      {
          printf("3");
      }
      return 0;
  }
  </code></pre>