title: Checking for palindrome string in c
body: <p>I am accepting a string as a command line argument. I want to check whether the inputted string is a palindrome or not and print the result. I have written the following code. But its displaying the result 'not palindrome' for all inputs.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  
  int main(int argc, char argv[20]) {
      int i;
      int l = strlen(argv);    
      char str[20];
      bzero(str, 20);
  
      for(i=0; i&lt;l; i++)
      {
          str[i] = argv[i+2];
      } 
      int flag;
      int len = strlen(str);
      for(i=0; i&lt; len/2; i++)
      {
          if(str[i] == str[len - (i+2)])
          {
              flag = 0;
          }
          else
          {
              flag = 1;
              break;
          }
      }
  
      if(flag == 0)
          printf("Palindrome\n");
      else
          printf("Not a palindrome\n");
  }
  </code></pre>