what about this. shouldn't this work? i got the idea from the last program we had to do.
Code:
#include <iostream>
#include <cstdlib>
#include <string>
string reverse(word);
void verify(string reversed, word);
////////////////// int main //////////////////////////////
int main (int argc, char * const argv[])
{
string word, reversed;
cout << "Please enter a word" << endl;
cin >> word;
reversed = reverse(word);
verify(string reversed, word)
return 0;
}
//////////////////// reverse the word ////////////////////////////
string reverse(word)
{
string word;
string wordr;
int i, j;
i = 0;
cout << "Please enter a word." << endl;
cin >> word;
j = word.size;
while (i <= j)
{
wordr[i] = word[j];
i++;
j--;
}
return wordr;
}
/////////////////// check reversed word /////////////////////////////
void verify(string reversed, word)
{
string wordr;
string word;
if (word == wordr)
{
cout << "This word is a pallendrome" << endl;
}
else
{
cout << "This word is not a pallendrom" << endl;
}
} if this could work, what did i do wrong?