Name: Anonymous 2010-05-03 18:07
Hey there /prog/, you guys seem less than retarded, so I'm asking you for your help. I need to do some palindromes, just single words, but I'm retarded.
Does anyone know why my Sepples codes doesn't work? 'x' isn't set to the right value no matter the input, which throws off the palindrome checking function, which sucks cocks.
Here's the code. Note, I cannot use any str functions.
Where am I fucking up?
Thanks, I love you /prog/
Does anyone know why my Sepples codes doesn't work? 'x' isn't set to the right value no matter the input, which throws off the palindrome checking function, which sucks cocks.
Here's the code. Note, I cannot use any str functions.
//Project 14 - Palindromes
#include <iostream>
using namespace std;
int main()
{
char str[100];
int x = 0; //Will be the string length
cout << "Enter a word to see if it's a palindrome: ";
cin >> str;
for(int i = 0; i < 100; i++) {
if (str[i] == '\0') {
x = i - 1;
}
}
cout << "X = " << x << endl;
for(int i = 0; i <= x; i++){
cout << str[i] << " " << str[x-i] << endl;
if (str[i] == str[x-i]) {
continue;
}
else {
cout << "That word is not a palindrome. " << endl;
return 0;
}
}
cout << "That word is a palindrome!" << endl;
return 0;
}Where am I fucking up?
Thanks, I love you /prog/