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
How to set file pointer to beginning c?
What is volatile c?
explain how do you use macro?
What is hungarian notation? Is it worthwhile?
What is cohesion and coupling in c?
What is the benefit of using #define to declare a constant?
When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.
Is c object oriented?
Why is python slower than c?
Who developed c language and when?
diff between exptected result and requirement?
How can type-insensitive macros be created?
What are the 5 elements of structure?
What is difference between structure and union in c?
Compare array data type to pointer data type