Palindrome words

Hi! I need help with this program :)
the user has to input some words but firstly give the number of the words he is going to give (N) . After the program has to find how many palindrome words the user gave and prin the number .This is what i 've done so far but i doesn't work.Can you please help me?

#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
int N,x,counter;
char chara[1000];
cin>>N;
for(int i=0;i<N;i++)
{
cin>>chara;
x=strlen(chara)-1;
cout<<x<<endl;
for(int j=0;j<=x;j++)
{

if(chara[j]==chara[x-j])

continue;

else
return 0;


}

counter++;

}
cout<<counter;
return 0;
}
You compare c-strings with the strcmp() function. The "==" operator won't work here.
See: http://www.cplusplus.com/reference/cstring/strcmp/
closed account (Dy7SLyTq)
A) what's up with your naming style?
B) why are you including <string> if you don't use std::string?
C) instead of cin>> chara I would do cin.getline
D) hes comparing characters not strings
Topic archived. No new replies allowed.