Attempting to make a text RPG

Hello, I am trying to make a text RPG and for the first part of the program I have it ask the user their name, a output statement welcomes the user with their name and then asks if it is correct. I am trying to make it where if the user says no the program continues to ask for the user to input their name and once they say yes it exits the loop. Thanks for any suggestions or help.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  #include <iostream>
#include <string>

using namespace std;

int main()
{
	string name;
	string yes;
	string no;
	bool answer;

	cout << "Welcome Hero, what is your name?" << endl;
	cout << "Please type in your name and press enter." << endl;

	getline(cin, name);

	cout << "Ah so your name is," << name << "?";
	cout << "Please answer yes or no." << endl;

	getline(cin,answer);

	while (answer = 'no')
{
	
	cout << "Oh I'm sorry, please enter your name and press enter." << endl;
	getline(cin, name);
	
}
In c++ assignment to variables is done with a single equal sign. Comparing two variables for equality is done with two equal signs. On line 23 of your code you are assigning a value instead of comparing two values. Also, in c++ strings are specified using double quotation marks ("), not single quotation marks(').
Thank you that did help.
Topic archived. No new replies allowed.