### Isolating parameters of an array, palindrome

So i have pretty much figured out how to do this code through a series of trial and error and professor assistance. But im stuck on this last part. For some reason when i take the contents of my array of characters, after it has been uppercased through toupper, my loop isnt wanting to isolate just the alphabet and numbers. Can someone please give me at least a hint in the right direction???

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150`` ``````#include #include #include // for set precision using namespace std; void center(string display); // Functions void showMenu(); void palindrome(); void stringinput(char*); int main() //main { char choice; //Constants for the menu choice cout << fixed << showpoint << setprecision (2); //Set decimal point to two figures (1/100th) do { fflush(stdin); //Display the menu and get the user's choice. showMenu(); while (! (cin >> choice) || !(choice == '1' || choice == '2' || choice == '3')) // Validate the menu selection. //Loop , and the the user input of what choice to do { center( "Are you drunk?? thats invalid order."); cout<< endl; cin.clear(); fflush(stdin); // Clear Input buffer. center ("Re-Enter your choice : "); } switch (choice) //Switch menu choices { case '1': // Box choice palindrome(); case '2': // Rainfall statistics choice fflush(stdin); cout << endl; center("Rainfall Statistics : "); break; case '3': // end program choice center ("Programmer: Andrew Holder"); cout << endl; center ("BYE BYE!!! Press key to END the program..."); fflush(stdin); cin.get(); break; } system("CLS"); //Clears screen and then reloops for the entire program } while (choice!= '3'); // THis is part of the do while loop that keeps continuing until you pick end program. cout << endl << endl; fflush(stdin); return 0; } void palindrome() { char word[80]; cout << "Please input a word and press return" << endl; fflush(stdin); stringinput(word); } void stringinput(char* word) { bool palindrome=true; char temp[80]; int i =0; cin.getline(word, 80); for( int i=0 ; i < strlen(word); i++ ) word[i] = toupper( word[i] ); for (unsigned i = 0; i < strlen(word); i++) //unsigned is positive integer { if ((word[i]>= 48 && word[i] <=57) || (word[i]>=65 && word[i]<=90)) // only takes numbers and alphabets and puts // and puts them into temp array. { temp[i]=word[i]; } } for(int i = 0; i< 80; i++) { cout << temp[i]; } char *front = temp,*rear = (temp + strlen(temp)) - 1; for(int i =0; front<=rear; front++,rear--) { if(*front != *rear) { palindrome=false; break; } //cin.get(); } if (palindrome==true) { cout << "The word is a palindrome" << endl; fflush(stdin); cin.get(); } else { cout << "The word is not a palindrome" << endl; fflush(stdin); cin.get(); } }``````
In line 111, i put a test there to see what was being stored and its a whole bunch of gobbly goop . thanks in advance you guys!
 ``12345678910111213141516171819202122232425`` ``````void stringinput(char* word) { bool palindrome=true; char temp[80] = {' '}; int i =0; int count = 0; cin.getline(word, 80); for( int i=0 ; i < strlen(word); i++ ) word[i] = toupper( word[i] ); for (unsigned i = 0; i < strlen(word); i++) //unsigned is positive integer { if (isalpha(word[i]) || isdigit(word[i])) // only takes numbers and alphabets and puts // and puts them into temp array. { temp[count] = word[i]; count++; } } for(int i = 0; i< strlen(word); i++) { cout << temp[i]; }``````
good looking bro, but the cout will still print out the symbols of the input in a very strange fashion if they are at the end of the string. Do you have any idea why that might be??? something to do with the null terminator??? i have no idea, huge beginner. Thank u dude for responding and even if i dont put any symbols or spaces in standard input, the cout does in fact make them all uppercase, but a palindrome like MADAM is coming back false....:/// What small glitch am i messing up on?? my algorithim seems to be right...

NEVER MIND!!! YOUR THE MAN! But for informational purposes, could you explain why initiliazing temp array { ' '} did the trick??? all of a sudden the program works could you explain that to me??? thanks alot man!
Topic archived. No new replies allowed.