I have three strings:

char str1[] = "My name is John";
char str2 = "My name is John also";
char final [10];

How would i go about comparing the first two strings, and put what is different (" also") into the third one?

Recommended Answers

All 4 Replies

What about other examples?
Is it word-based, or character based?

char str1[] = "My name is John";
char str2[] = "My name also is John";
//
char str1[] = "My name is John";
char str2[] = "Mya namel iss Johno";

Character based.
However, I'm only need to check for changes at the end of the string.
I've just realized that I can loop through and check each char, but I'm wondering if there is a built in/easier way?

There is no built in way. Easier? Can't think of anything easier than checking characters.

i dont whether it will work or not, did u try out strstr() funtion

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.