1 .Using
function
#include
<stdio.h>
#include
<string.h>
int main()
{
char a[100], b[100];
printf("Enter the first
string\n");
gets(a);
printf("Enter the second
string\n");
gets(b);
strcat(a,b);
printf("String obtained on
concatenation is %s\n",a);
return 0;
}
2.Without
using function
#include
<stdio.h>
void
concatenate_string(char*, char*);
int main()
{
char original[100], add[100];
printf("Enter source string\n");
gets(original);
printf("Enter string to concatenate\n");
gets(add);
concatenate_string(original, add);
printf("String after concatenation is
\"%s\"\n", original);
return 0;
}
void
concatenate_string(char *original, char *add)
{
while(*original)
original++;
while(*add)
{
*original = *add;
add++;
original++;
}
*original = '\0';
}