I have to manipulate strings so that, we need to check if a string needs to be combined with another string. Need to use a library function for this.

Suppose, we have

S1. This is an apple
s2. apple is sweet
so, the combined line should be: This is an apple is sweet

s1. This is an apple
s2. e that I bought
Combined: This is an apple that I bought

I used nested for loops for this and it makes it too complicated. Is there a string library function that I can use?

I will have bunch of lines of sentences, and I need to combine them to form one sentence.
I need to combine lines that match the most, not just 2 lines that match.

Take a look at strcat.
But strcat on it's own won't solve the whole thing, you'll have to do some other things as well, things which I'd like you to try figure them out on your own.
When you run into problems you still can fall back to this thread.

I have to manipulate strings so that, we need to check if a string needs to be combined with another string. Need to use a library function for this.

Suppose, we have

S1. This is an apple
s2. apple is sweet
so, the combined line should be: This is an apple is sweet

s1. This is an apple
s2. e that I bought
Combined: This is an apple that I bought

I used nested for loops for this and it makes it too complicated. Is there a string library function that I can use?

I will have bunch of lines of sentences, and I need to combine them to form one sentence.
I need to combine lines that match the most, not just 2 lines that match.

U can use the functions strstr() and strcat() to do the above. Read their manual.

**********************answer
#include<stdio.h>
void main()
{int i,j;
 char str1[30];
char str2[15];

puts("enter string1");
gets(str1);
puts("enter string 2");
gets(str2);



for(j=0,i=0;str1[i]!='\0';i++)
{
    if(str2[j]==str1[i])
    {
    printf("%c",str2[j]);
    j++;

    }


}

    while(str2[j]!='\0')
    { str1[i]=str2[j];
     j++;
        i++;
    }
str1[i]='\0';
printf("%s",str1);
}
*******************
commented: using gets(), void main(), no CODE tags, and answering the question without letting allensmith try it first -2
commented: Seconded. -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.