int main(){
char str1[MAX], str2[MAX];
cout <<" 1st string: ";
cin.get(str1, MAX);
cout <<" 2nd string";
cin.get(str2, MAX);
cout << str1 << str2;
return 0;
}
I am trying to input a string with spaces included in both arrays str1 and str2. The problem is program terminates after taking the first input.
On the output screen:
1st string : abc def
Now when I press enter to take input for 2nd array but then the code terminates and first string is displayed.
Output: 2nd string
abc def
How can I properly use this cin.get() function to take 2 different inputs? Is there any other way to take string with blank spaces for char array ?