chris200x9
January 28th, 2008, 07:03 PM
Hi, what is wrong with this :confused::confused::confused:
// polandrom.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
int counter2;
string word2;
string word;
int counter = 0;
cout << "input a word you think is a pallindrome" << endl;
cin >> word;
counter2 = word.length();
counter2 = counter2 - 1;
while (counter2 != -1 )
{
word2[counter] = word[counter2];
counter++;
counter2--;
}
word2[counter] = '\0';
if ( strcmp(word.c_str(), word2.c_str()) == 0)
{
cout << "you got yourself a pallindrome there, buddy"; << endl;
}
else
cout << "no pallindrome for you!"; << endl;
return 0;
}
help it compiled fine in windows but now I am getting an error about both cout statements in the if/else statement.
// polandrom.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
int counter2;
string word2;
string word;
int counter = 0;
cout << "input a word you think is a pallindrome" << endl;
cin >> word;
counter2 = word.length();
counter2 = counter2 - 1;
while (counter2 != -1 )
{
word2[counter] = word[counter2];
counter++;
counter2--;
}
word2[counter] = '\0';
if ( strcmp(word.c_str(), word2.c_str()) == 0)
{
cout << "you got yourself a pallindrome there, buddy"; << endl;
}
else
cout << "no pallindrome for you!"; << endl;
return 0;
}
help it compiled fine in windows but now I am getting an error about both cout statements in the if/else statement.