Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Concat two string with most overlapped substring has to
removeĀ  "abcd"+ "cdef" = "abcdef

Answer Posted / ashwin kumar

the code given by tarak is correct

ie

#include<stdio.h>
main()
{
char *a="abcd";
char *b="cdef";
char c[10];
int i=0;
while(*a != *b)
{
c[i] = *a++;
i++;
}
while(*b != '\0')
{
c[i]= *b++;
i++;
}
printf("%s\n",c);
}



but the answer is abcdef and some garbage values yar

abcdef{}>>>M<C<P{{

to get perfect answer just add '\o' at end of the code and
before printf dear




#include<stdio.h>
main()
{
char *a="abcd";
char *b="cdef";
char c[10];
int i=0;
while(*a != *b)
{
c[i] = *a++;
i++;
}
while(*b != '\0')
{
c[i]= *b++;
i++;
}

c[i]='\0'; //// new added line here






printf("%s\n",c);
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the advantages and disadvantages of c language?

962


Why c is a mother language?

965


What is the use of linkage in c language?

1011


What is the difference between formatted&unformatted i/o functions?

1007


Can you write the algorithm for Queue?

2029


What is difference between far and near pointers?

986


What is meant by inheritance?

1048


What does a pointer variable always consist of?

1042


What is meant by recursion?

997


What is a null pointer in c?

1124


Write a c program to demonstrate character and string constants?

2114


What is %lu in c?

1180


Differentiate between functions getch() and getche().

988


Explain what is output redirection?

1136


What is the difference between near, far and huge pointers?

1033