C++ Program to Concatenate Two Strings

C++ program to concatenate two input strings using while loop.

C++ program to concatenate two strings

#include <iostream>
#include <cstring>
using namespace std;
int main(){
    char first[1000], second[1000];
    int i = 0, len;
    cout << "Enter first string"<< endl;
    cin.getline(first, 1000);
    cout << "Enter second string"<< endl;
    cin.getline(second, 1000);
    len = strlen(first);
    while(second[i] != '\0'){
     first[len] = second[i];
    first[len] = '\0';
    cout << "Concatenated String"<< endl<< first;

    return 0;
Enter first string
Enter second string
Concatenated String

Recommended Posts
C++ Program to Check whether a string is Palindrome or Not
C++ Program to Copy String Without Using strcpy
C++ Program to Print Array in Reverse Order
C++ Program to Delete Spaces from String or Sentence
C++ Program to Delete Vowels Characters from String
C++ Program to Convert Uppercase to Lowercase Characters
C++ Program to Multiply Two Numbers Using Addition
C++ Program to Store Information of a Book in a Structure
C++ Program to Calculate Difference Between Two Time Periods
All C++ Programs