Program to Insert a substring in a main string.

/* We have a main string and a sub string that has to be inserted somewhere in main string according to user. User insert main string and substring both, as well as he entered index where substring has to be inserted. If we have space in main string and we want to keep the main string in proper format as we insert than we have to add space along with substring as input. */

#include
#include

void insert(char sup[], char sub[], int pos,int supl, int subl)
{int i,j,n;
n=supl+subl;
char temp[1000];
printf(“\nsupl= %d\n”,supl);
printf(“\nsubl= %d\n”,subl);

for(i=0;i<pos;i++)
temp[i]=sup[i];

for(j=0;j<subl;j++,i++)
temp[i]=sub[j];

for(;pos=supl || pos<0)
{puts(“\nArray out of bound! You entered invalid index.”);
exit(1);
}
else insert(sup,sub,pos,supl,subl);
}

Advertisements

2 thoughts on “Program to Insert a substring in a main string.

  1. I discovered your “Program to Insert a substring in a main string. | Code World Technology” page and noticed you could have a lot more traffic. I have found that the key to running a website is making sure the visitors you are getting are interested in your subject matter. There is a company that you can get traffic from and they let you try it for free. I managed to get over 300 targetted visitors to day to my website. Check it out here: http://nsru.net/fdse

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s