C Programming Code Examples C > Strings Code Examples Program to concatenate two strings using pointer Program to concatenate two strings using pointer Write a C program to concatenate two strings in single string. How to concatenate two strings to one without using strcat() library function. Adding two strings into one without using inbuilt library function. Logic to concatenate two strings in C programming. C program to concatenate two strings using strcat() library function. Concatenation of strings Concatenation of two strings is the process of joining them together to form a new string. Concatenation appends the second string after first string. Concatenation is sometimes also referred as binary addition of strings i.e. + operation. For example: I love + Happy Codings = I love Happy Codings Logic to concatenate two strings Concatenation of two strings is simple copying a string to another. To concatenate two strings str1 and str2, you will copy all characters of str2 at the end of str1. Input two string from user. Store it in some variable say str1 and str2. Here we need to concatenate str2 to str1 Find length of str1 and store in some variable say i = length_of_str;. Run a loop from 0 till end of str2 and copy each character to str1 from the ith index. #include <stdio.h> #define maxsize 100 // Maximum string size int main() { char str1[maxsize], str2[maxsize]; char * s1 = str1; char * s2 = str2; /* Input two strings from user */ printf("Enter first string: "); gets(str1); printf("Enter second string: "); gets(str2); /* Move till the end of str1 */ while(*(++s1)); /* Copy str2 to str1 */ while(*(s1++) = *(s2++)); printf("Concatenated string = %s", str1); return 0; }