I know that you guys are all probably Palindromed out but I wrote a program and it's telling me that m is an undeclared identifier and also a unreferenced local varibale errors....any idea on how to fix it??
Code:
#include <iostream>
#include <string>
using namespace std;
//PROTOTYPE
string Reverse(string s, int m); //reverse s from
bool IsPalindrome(string s); // Checks if it is Palindrome
// MAIN PROGRAM
int main () {
string word;
string s;
int m;
cout << " What word would you like to test to see if it is a Palindrome?"<< endl;
cin >> word;
string Reverse();
bool IsPalindrome();
return 0;
}
//IMPLEMENTATION OF PROTOTYPE
string Reverse(string s, int m) {
string t = ""; //null string
int strlength=s.length();
if (m == s.length()-1){
return t+s[s.length()-strlength]; //the iterator takes the place of the '1'
} else {
return s[s.length()-m-1] + Reverse(s, m+1); // recursive call
}
}
bool IsPalindrome(string s) {
string Reverse(string s, int m);
if ( Reverse( s, m) == word){
return true;
}
else {
return false;
}
}
[edit]Code tags added by Hammer