by Dinesh Thakur Category: Array
#include <Stdio.h>

#include <conio.h>
main()
{
      char text[200],str[20], new_text[200];
      int i=0, j=0, found=0, k, n=0, copy_loop=0;
      clrscr ();
      printf("\n Enter the main text: ");
      gets(text);
      fflush (stdin);
      printf("\n Enter the string to be deleted: ");
      gets(str);
      fflush(stdin);
   while(text[i] !='\0')
   {
                  j=0, found= 0, k=i;
             while (text[k]==str [j] && str [j]!='\0')
              {
                             k++;
                             j++;
              }
                 if (str [j]=='\0')
                 {
                         copy_loop=k;
                 }
                         new_text[n] = text[copy_loop];
                         i++;
                         copy_loop++;
                         n++;
   }
                  str[n]='\0';
                  printf("\n The new string is: ");
                   puts(new_text);
              getch();
   return 0;
}

   delete a substring from a text



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles