View Single Post
Old 10-23-2004, 03:31 PM   #4 (permalink)
Androto
Mac Os X User(I hate win)
 
Join Date: Oct 2004
Posts: 138
Androto is on a distinguished road
ok. txh for all your hard work, but i really want to use my onw code, and i can barely recognize my own code in there. i fixed up my own code as much as i could, but i can't figure out what the following error means:

decleration of 'word' shadows parameters

and

parse error before ','


how could i fix that? here's the code with all of my corrections. i used some of the tips you gave me.
Code:
#include <iostream>
#include <cstdlib>
#include <string>

string reverse(string word);
void verify(string reversed, string 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, string word);
	return 0;
}
//////////////////// reverse the word ////////////////////////////
string reverse(string word)
{
	string wordin;
	string wordr;
	int i, j;
	i = 0;
	cout << "Please enter a word." << endl;
	cin >> wordin;
	j = wordin.size();
	while (i <= j)
	{
		wordr[i] = wordin[j];
		i++;
		j--;
	}
return wordr;
}
/////////////////// check reversed word /////////////////////////////
void verify(string reversed, string word)
{
	string wordr;
	string wordin;
	if (wordin == wordr)
	{
		cout << "This word is a palindrome" << endl;
	}
	else
	{
		cout << "This word is not a palindrom" << endl;
	}
}
Androto is offline   Reply With Quote