View Single Post
  #1 (permalink)  
Old February 15th, 2005, 01:35 PM
RCB RCB is offline
Registered User
 
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Confusing problem in C++

please help me with this
I'm having problem with this code
what im trying to do is ask the user to type a line
and i read it as a character, one character at a time. no strings or arrys ..
if the line has a colon in it, it should be changed to a period.
and if there is 'and' after the colon then it should be removed and capitalize the first letter of the next work, if there is no 'and' then just capitalize the word after the colon.
i managed to change the colon to a period but i am having problem making it recognize the word and
 my code
int main()
{

 char c, colon=',';
 ch= cin.get();
 while (ch = cin.get())
  {
    if (ch == colon)
    {
        ch ='.';
        if (ch == 'a')
           {
            if (ch=='n')
             {
              if (ch=='d')
                {
                 cin.ignore();
                 }
               }
            }
      }
     cout << ch;
   }
}

Reply With Quote