use getline to read char array based string
#include <iostream>
#include <string >
using std::cout;
using std::cin;
int main()
{
char s1[40],s2[40],s3[40];
int size;
cout << "Please enter a word \n";
cin.getline(s1,40);
cout << "Please enter another word \n";
cin.getline(s2,40);
size = strlen(s1);
strcat(s1,s2);
cout << "The length of the first string you entered is" << size << "\n";
cout << "Both strings you entered are " << s3<< "\n";
return 0;
}
Related examples in the same category