I am trying to code a Palindrome program...I keep on getting a runtime error called
Index out of range: 3 string: mom
yeah I can't figure out why though...here's my code
Code:
void Palindrome()
{
apstring Input;
apvector<char> Word;
apvector<char> ReversedWord;
int Length = 0;
int c = 0;
int d = 0;
bool Palindrome = true;
cout << endl;
cout << "Enter in a word to see if it is a palindrome: ";
cin >> Input;
ToLower(Input);
Length = Input.length();
Word.resize(Length);
ReversedWord.resize(Length);
for(int b = Length; b > 0 ; b--)
{
Word[d] = Input[b];
d++;
}
for(int i = Length; i > 0; i--)
{
ReversedWord[c] = Word[i];
c++;
}
for (int e = 0; e < Length; e++)
{
if(ReversedWord[e] == Word[e])
{Palindrome = true;}
else
{Palindrome = false;}
}
if (Palindrome == true)
{cout << "This word is a palindrome." << endl;}
else
{cout << "This word is not a palindrome." << endl;}
}
yeah this is it by the way my headers are
<iostream.h>
<strutils.h>
<apstring.h>
"apvector.h"
yeah thanks for your help