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
What are the __date__ and __time__ preprocessor commands?
What is null in c?
What is variables in c?
What is NULL pointer?
What does nil mean in c?
I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.
What is a constant?
how to count no of words,characters,lines in a paragraph.
What are the key features in c programming language?
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
What is the maximum length of an identifier?
Why is c still so popular?
List the difference between a While & Do While loops?
Why we not create function inside function.
How to explain the final year project as a fresher please answer with sample project