title: Palindrome program & unwanted chars in c-style string
body: <pre><code>#include &lt;iostream&gt;   
  #include &lt;string&gt;   
  using namespace std;
  
  int main()
  {
      string word1;
      cout &lt;&lt; "\nEnter a string : ";
      getline(cin, word1);
      string word2 = word1;
      int size = word2.size();
      char word3[20];
      int y = 0;
  
      for (int x = size - 1; x &gt;= 0; x--)
      {
          word3[y] = word2[x];
          y++;
      }
  
      if (word1 == word3)
      {
          cout &lt;&lt; "\nOutput: 1";
      }
      else
      {
          cout &lt;&lt; "\nOutput: 0";
      }
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>This code allows user to input a word and the computer detrmines if the word is a palindrome or not.  It does this by taking the word and pirinting it backwards.  Then it compares it to the original word.  I've debugged my code using breakpoints and the autos, local, and watch window and last letter of word2 is being assigned to the first letter of word3 (as it should).  But after the entire process, word3 is still full with a bunch of crazy characters that you don't see if you were just to print word3 to screen (if the original word was "hello" it would give the other string "ollehÍÍÍÍÍÍÍÍÍÍ...").  Because of this, the computer thinks that the originala nd the first words are not the same (even when they are).  Question: How do I get rid of  these "ÍÍÍÍÍÍ..." characters in my string. (I used c-style string because string object came with it's own set of complications.  It said something about the subscipt being exceeded and only worked if I initialized it with spaces equal to the amount of chars in the word I would enter)."</p>