Table of Contents
show
Use of strncat( ) function
#include<stdio.h>
#include<string.h>
int main()
{
char src[50];
char dest[50];
int n;
puts("Enter string1:");
gets(src);
puts("Enter string2:");
gets(dest);
puts("Enter the number of characters to copy");
scanf("%d",&n);
puts("strings are:");
puts(src);
puts(dest);
strncat(dest,src,n);
puts("After Concatenation :");
puts(dest);
return 0;
}
Output
Enter string1:
Welcome
Enter string2:
all
Enter the number of characters to copy
3
strings are:
Welcome
all
After Concatenation :
allWel
Views: 0