I'm using Visual C++ 6.0 and currently created a program that will print the output stored in string.
The problem is when I entered words with space, only the first word is visible in the output.
Example:
Enter your address: new york
new
Press any key to continue
I want this:
Enter your address: new york
new york
Press any key to continue
Also, I tried to use getline
but when I entered words, It will first print blank space then stored the last output before the current one.
Here's my code:
#include <iostream>
#include <string>
using namespace std;
void main()
{
string address1;
cout<<"Enter your address:";
cin>> address1;
// getline(cin, address1); code when using getline
cout<<address1<<"\n";
}