Read Line Program

Write a program that will read a line and delete from it all occurences of the word 'the'

Questions by Vinod G S

Showing Answers 1 - 1 of 1 Answers

main()
{
 char q[100],r[100];
 printf("Enter the linen");
 gets(q);
 char *p=r;
 char *s=q;
 while(*s)
 {
  if(*s=='t'||*s=='T')
  {
   s++;
   if(*s=='h' || *s=='H')
   {
    s++;
    if(*s=='e'||*s=='E')
     s++;
    else
     s-=2;
   }
   else
    s--;
  }
  *p=*s;
  p++;
  s++;
 }
 *p='';
 printf("the new line after deleting 'the' is :n");
 puts(r);
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions