+ 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; }

8th Dec 2018, 12:02 PM
Jothika
Jothika - avatar
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)
8th Dec 2018, 1:30 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 3
Use 'cin >> s1;' to read the string
8th Dec 2018, 12:52 PM
Walef
Walef - avatar