Original Post
Hi guys...
My little project here is becomming very compliacted
Im trying to find out if a string is a palindrome by using pointers.
This code here compiles without an error but crashes whenever i run it
char e, e2;
char *ePtr, *e2Ptr;
e = writePtr[ 0 ];
ePtr = &e
e2 = writePtr[ numberofchars ];
e2Ptr = &e2
if ( numberofchars % 2 == 0)
{
//number is even so check first and last moving inwards
for ( int a = 0; a < numberofchars / 2; ePtr++, e2Ptr-- )
{
if ( *ePtr == *e2Ptr)
{
//we gotta match!
numberofpals++;
}
}
if ( numberofpals == ( numberofchars / 2) )
{
cout << "Palindrome" << endl;
return true;
}
}
Any assistance would be greatly appreciated
Thanks a lot.