title: How to get palindromes using pointer in c?
body: <p>I apologize that I cannot use English fluently because I am not a English speaker.</p>
  
  <p>I want to get palindromes such as "A man, a plan, a canal, Panama!" or "Was it a car or a cat I saw?"</p>
  
  <p>I studied Pointer in C today. So I made code to get palindromes.</p>
  
  <pre><code>#include &lt;ctype.h&gt; 
  /**
  * @brief : Check if the given str is a palindrome
  * @return: 1 if the given str is a palindrome, zero otherwise
  * @param : str - pointers to the null-terminated byte string to check
  */
  int ispalindrome(char *str)
  {
      int i, j;
      char *pal;
      for(i=0 ; *str!=0; i++) {
          if(ispunct(*str)){  //if *str is punctuation mark, do not anything.
              str++;
          }   
          else if(isupper(*str)){  //if *str is a capital letter, change it to small letter and *pal=*str
              *pal = tolower(*str);
              str++;
              pal++;
  
          }
          else //if *str is a small letter or a digit, *pal=*str
              *pal = *str;
              str++;
              pal++;  
      }
      for(j=0; pal[j]==pal[i-(j+1)] &amp;&amp; j&lt;=i/2; j++) //compare pal 
          ;
      if(j&gt;i/2)
          return 1;
      return 0;
  }
  
  int main(void)
  {
      char buffer[1024];
      int i;
      gets(buffer);
      printf("[%s] is ", buffer);
      if (ispalindrome(buffer))
          puts("a palindrome");
      else
          puts("not a palindrome");
      return 0;
  }
  </code></pre>
  
  <p>However, there is logical error.
  When I input anything, the output is always palindrome.</p>
  
  <p>I don't know where are errors.</p>
  
  <p>For example,
  for get "A man, a plan, a canal, Panama!", I removed(disregarded) 'space' and 'punctuation marks', changed capital letters to small letter. (amanaplanacanalpanama)
  However, when i input like 'abcdef', I got also "[abcedf] is a palindrome."</p>