Some Help Please!

Why does my code not loop back to the start when "namechange" = 0. The code just stops after it outputs "Here you will be able to start your very own business! Making your own ice cream shop."

Please Help! Thanks!


#include <iostream>
#include <cstdlib>
#include <time.h>
#include <windows.h>

using namespace std;

int main()
{
string name;
int namechange;
int y;
int n;
int decision;


cout << "******************************************************";
cout << " Welcome to Ice Cream Tycoon!" << endl;
cout <<"*******************************************************";
cout << "Here you will be able to start your very own business! Making your own ice cream shop." << endl;

while (decision = 0) //Loop for name change
{

cout << endl;
cout << "To begin please enter your name" <<endl;

cout << endl;
cout << "<< ";
cin >> name;
system ("CLS");

cout << "Hello " << name <<endl;
cout << "Would you like to change your name?" << endl;
cout << "Enter Y to change name. Enter N to continue." << endl;

if (namechange == y)
decision = 0;
else if (namechange == n)
decision = 1;
}


return 0;
}
= is assignment.
== is comparison.

1
2
3
4
while (0)
{
    ....
}
is equivalent to:
1
2
3
4
// while(0)
// {
//      ...
// } 
Changed == into = but still doesn't fix the code stopping after "Here you will be able to start your very own business! Making your own ice cream shop."
Changed == into =

That would not be correct. Change = to == in your while condition (and ensure you initialize decision before using it.)
Topic archived. No new replies allowed.