having a cin >> Username error

fairly new to C++ and still running into errors here and there. heres my latest error.


1
2
3
4
5
  string Username;
	cout << "Choose your username!";
	cin >> Username;
	cin.ignore();
        cout << "Welcome "  << Username <<" to Perfect Sense "<< endl;




Line 1 - naming Username as a Sring
Line 2 - Printing out "Choose your username!"
Line 3 - Trying to store the input from Line 2 in the String Username

The errors that I am getting are on Line 3 and Line 5 on >> (line 3) and the first << on line 5. any help would help
Your code works.

make sure you include <iostream> and <string> and are using namespace std;
Last edited on
Thank you!

Newbie me, didnt include #include <string>
Your welcome. And in this instance,

1
2
3
4
5
string Username;
cout << "Choose your username!";
cin >> Username;
cin.ignore();
cout << "Welcome "  << Username <<" to Perfect Sense "<< endl;


works the same.
Topic archived. No new replies allowed.