View Single Post
  #2 (permalink)  
Old February 16th, 2005, 06:54 AM
karthikbachu karthikbachu is offline
Registered User
 
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi
  I hope the following modifications in ur code will solve ur problem.
#include<iostream.h>
#include<ctype.h>
void main()
{
 char ch, colon=':',tmp,tmp1,tmp2,tmp3;
 ch= cin.get();
 int i;
 while (ch!='\n')
  {
  if (ch == colon)
    {
    ch ='.';
    cout<<ch;
    ch=cin.get();
    tmp=ch;
    if (ch == 'a')
    {
        Ã‚ ch=cin.get();
        Ã‚ tmp1=ch;
        Ã‚ if (ch=='n')
        Ã‚ {
        Ã‚  ch=cin.get();
        Ã‚ tmp2=ch;
        if (ch=='d')
        Ã‚ {
       cin.ignore();/*if there is space after and use this line*/
        Ã‚ ch=cin.get();
        Ã‚ i=toupper(ch);
        Ã‚ ch=(char)(i);
        Ã‚ cout<<ch;
        Ã‚  }
        Ã‚ else
        Ã‚  {
        Ã‚   i=toupper(tmp);
        Ã‚   ch=(char)(i);
        Ã‚   cout<<ch;
        Ã‚   cout<<tmp1;
        Ã‚   cout<<tmp2;

        Ã‚  }
        Ã‚  }
        Ã‚  else
        Ã‚  {
        i=toupper(tmp);
        ch=(char)(i);
        cout<<ch;
        cout<<tmp1;

        Ã‚  }

    }
    Ã‚   else
    Ã‚   {
    i=toupper(tmp);
    ch=(char)(i);
    cout<<ch;
    }
    }
  else
   {
    Ã‚ cout<<ch;
   }

   ch=cin.get();

    }
}
This is not the only solution..there may be many solutions better than this....
Reply With Quote