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
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

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

  1. Write more, thats all I have to say. Literally, it seems as
    though you relied on the video to make your point.
    You obviously know what youre talking about, why throw away
    your intelligence on just posting videos to your site when you
    could be giving us something informative
    to read?

  2. Attractive section of content. I simply stumbled upon your blog and in accession capital to
    claim that I acquire in fact loved account your blog posts.
    Any way I will be subscribing to your augment and even I fulfillment you get right
    of entry to persistently quickly.

  3. Nice post. I was checking constantly this blog and I’m impressed! Very helpful info specially the last part 🙂 I handle such info much. I was seeking this particular info for a very lengthy time. Thank you and best of luck.

  4. Howdy! I could have sworn I’ve visited this site before but after browsing through many of the posts I realized it’s new
    to me. Nonetheless, I’m definitely delighted I discovered it and I’ll be bookmarking it and
    checking back often!

  5. I like the helpful information you provide in your articles.
    I will bookmark your weblog and check again here regularly.
    I am quite sure I’ll learn many new stuff right here! Best of luck for the next!

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