EmbLogic's Blog

concatinate two strings using function,pointer and memory allocation

#include<stdio.h>
#include<stdlib.h>
int main()
{
char a[20]={0},b[10]={0};
int i,j=0;
printf(“Enter name1:\n”);
scanf(“%s”,a);
printf(“Enter second name:\n”);
scanf(“%s”,b);
for(i=0;i<20;i++)
{
if(a[i]==”)
{
a[i]=b[j]; j++;
}
}
printf(“Concatination is: %s\n”,a);
return 0;
}

 

note: – output

enter the name 1=hye

enter the name 2=dude

concatination is hyedude

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>