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]; len++; i++; } first[len] = '\0'; cout << "Concatenated String"<< endl<< first; return 0; }Output
Enter first string Tech Enter second string CrashCourse Concatenated String TechCrashCourse
Recommended Posts