View Single Post
  #4 (permalink)  
Old February 26th, 2005, 07:35 PM
C@uark C@uark is offline
Authorized User
 
Join Date: Oct 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to C@uark
Default

here are some mods that work

# include <iostream.h>
# include <ctype.h>



int main()
{
    char ch;
    ch=cin.get();
    do
    {
        switch(ch)
        {
        case 'A':
        case 'a':
        case ':':
            {
                // If colon
                if(ch==':')
                {
                    // change colon to period
                    cout<<". ";
                    // check to see if the next char is a space or character
                    if((ch=cin.peek())==32)
                    {
                        // Found white space ignore and get next character
                        cin.ignore();
                        ch=cin.get();
                    }
                    else
                        // Not a white space get next charater
                        ch=cin.get();
                }

                // check for the word "and"
                if(ch=='a'||ch=='A')
                {
                    if((ch=cin.get())=='n'||ch=='N')
                        if((ch=cin.get())=='d'||ch=='D')
                        {
                            // check for white space following "and"
                            if((ch=cin.peek())==32)
                                // If white space ignore
                                cin.ignore();
                            else
                                // character found insert space
                                cout<<" ";
                        }
                }
                // "and" deleted and/or next word capitalized
                cout<<(ch=toupper(ch=cin.get()));
            }
            break;
        default:
            { // print out every other leter
                cout<<ch;
            }
        }// get next character
    }while(ch=cin.get());
    return 1;
}
Reply With Quote