Sunday, October 3, 2010

Replace the with a


/********************************
*         program to replace the               *
*                    with a                                *
*********************************/
#include
#include
void main()
{
    int n,i,j,m;
    char str[50];
    clrscr();
    printf("enter any string");
    gets(str);
    i=0;
    while(str[i]!='\0')
    {
        if((str[i]==' ' || i==0) && str[i]=='t' && str[i+1]=='h' && str[i+2]=='e'&& ( str[i+3]==' ' || str[i+3]=='\0') )
        {
            str[i]='a';
            n=i;
            j=++i;
            m=i+2;
            while(str[j]!='\0')
            {
                str[j]=str[m];
                j++;
                m++;
            }
            i=n;
        }

        i++;
    }
    puts(str);
    getch();

}



No comments:

Post a Comment