A simple C program which concats two strings. the second string appends to first string and forms a concatenated string. Here string concatination is done without using strcat() function. Look below for program and the screenshot, |
PROGRAM :
#include<stdio.h> #include<string.h> int main() { char string1[50], string2[50]; int i, j; printf("\nEnter First string :"); gets(string1); printf("\nEnter Second string :"); gets(string2); i = strlen(string1); for (j = 0; string2[j] != '\0'; i++, j++) { string1[i] = string2[j]; } string1[i] = '\0'; printf("\nConcatinated string is :%s\n", string1); return (0); }
OUTPUT :
C Program - String concatenation without strcat |