View Single Post
Old 10-29-2004, 03:09 PM   #5 (permalink)
gamehead200
Code Monkey
 
gamehead200's Avatar
 
Join Date: Oct 2004
Posts: 57
gamehead200 is an unknown quantity at this point
Valmont, I'm doing the same thing as Andrew, except a different way... What am I doing wrong??

Code:
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{
    int i = 0;
    string word, wordreverse;
    unsigned size;
    
    ifstream in_file("c://Temp//scrabble.txt");  // open a file at this location
	
    while( !in_file.eof() ) 
    {        
        while( in_file >> word )
        {
            size = word.size();  // count number of letters in the word
            
            while( i < size )  // while i is less than size, reverse the word
            {
                wordreverse += word[size-i-1];
                i++;  // increment i
            }
            
            if( word == wordreverse )  // compare the two words
            {
                cout << word << " is a palindrome." << endl;  // if palindrome
            }
            
        }    
        
    }   
       
    system("PAUSE");	
    return 0;
}
gamehead200 is offline   Reply With Quote