+ 4
What is the error
What is the error pls may I know? #include <iostream> using namespace std; int main() { char s1[10], s2[10]; cout<<"Enter string 1:"; getline(cin,s1); cout<<"Enter string 2:"; getline(cin,s2); cout<<strcat(s1,s2); return 0; }
2 Answers
+ 10
First of all add cstring library because strcat function is defined in the cstring library.
Secondly, i would recommend you to use cin.getline() instead of getline().
Syntax for cin.getline() function :
cin.getline(name_of_array, size_of_array)
+ 3
Use 'cin >> s1;' to read the string