how do you debug this?

I cant make it run properly..it should read words if the inputted words are palindromes..but it always comes out not a palindrome help

#include <cstdlib>
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;

int main(int argc, char *argv[])
{
cout<<"\nEnter a word: \n";
char pal[10],drome[10], p[10], d[10];
gets(pal);
strcpy(p,pal);
strrev(p);
strcpy(d,p);
strcmpi(d,pal);

if (d==00)
puts("Palindrome");
else
puts("not a palindrome");


system("PAUSE");
return 3;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <sstream>
using namespace std;

bool isPalindrome(string s) {
	string tmp = s;
	int j = 0;
	for (int i = s.length()-1; i > 0; i--) {
		tmp[j] = s[i];
		j++;
	}
	if (tmp == s) {
		return true;
	}
	return false;
}

int main() {
	string s;
	cout << "Enter a string: ";
	getline(cin, s);
	if (isPalindrome(s)) {
		cout << "It is a palindrome." << endl;
	} else {
		cout << "It is not a palindrome." << endl;
	}
	system("pause");
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
     string a;
     getline(cin, a);
     if (a==reverse(a.begin(), a.end())) cout<<"It is a palindrome"<<endl;
     else cout<<"It's not a palindrome"<<endl;
     system("pause");
     }
Topic archived. No new replies allowed.