how to find out the union of two character arrays?

Answer Posted / prakashdasari

char *str1,*str2,*res;
while(*str1!=NULL)
str++;
while(*str2!=NULL)
{
*str1 == *str2;
str1++;
str2++;
}
*str1 = '\0';
//so total string is in one string ie str1 itself;
//now i will remove duplicates from entire string
for(i=0;str[i]!=NULL;i++)
{
for(j=0;str[j]!=NULL;j++)
{
if(str[i]==str[j])
{
flag = 1;break;
}
else flag = 0;
}
if(flag == 0)
{
*res = str[i];
res++;
}
*res = '\0';
}
now resultant string (res) is union of two character
arrays....

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is variable in c example?

590


What is a pointer value and address in c?

627


What is conio h in c?

614


What is an auto variable in c?

746


How are pointers declared in c?

590






What is null in c?

594


what are enumerations in C

716


Why void is used in c?

558


Hai what is the different types of versions and their differences

1482


What are shell structures used for?

593


Write a program to print factorial of given number using recursion?

598


What is the use of linkage in c language?

611


What is the total generic pointer type?

718


What is a structural principle?

634


How to write c functions that modify head pointer of a linked list?

539