What is wrong with this code? why does it play thought the whole thing without any user input at the choices? and why do the names display as random numbers after you put it in?
And also please feel free to give me tips on how to improve this code please.:D
Any help would be great, thank you for reading.
#include <iostream>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::string;
main()
{
//setting infomation
constint GOLDEN_COINS = 2000, MAX_ITEMS = 10;
int NAME, TEAM, choice1;
//Getting the information from player.
{
//Players name
{
cout << "\t Hello and welcome to my text based game - By kevindav1.";
cout << "\n Please enter your";
cout << "name: ";
cin >> NAME;
cout << "\n\nYour name is " << NAME << ". Is this correct?";
// Are you sure loop
{
cout << "Thank you for giving us your name," << NAME << ".";
cout << " Are you sure?";
cout << "\n\nYes - 1\n\nNo - 2";
cout << "\n\nChoice: ";
cin >> choice1;
switch (choice1)
{
case 1:
break;
case 2:
cout << "You have one last chance to get this right.";
cout << "\n Please enter your name: ";
cin >> NAME;
break;
}
cout << "Thank you for giving us your name," << NAME << ".";
}
}
}
//How many people are in there squad?
{
cout << "How many people are in your special forces squad?";
cout << "Number: ";
cin >> TEAM;
cout << "Are you sure " << NAME << "? That's quite i nice size squad of " << TEAM <<".";
}
}
On the console window when i play it, it says "please enter your name: "Then i enter "hello".
Then it says "Thank you for giving us your name,4273392."
1 2 3 4 5
cout << "\n Please enter your";
cout << "name: ";
cin >> NAME;
cout << "\n\nYour name is " << NAME << ". Is this correct?";
Also just because it lets you compile without int infront of main doesn't mean you should. It is best do do int main
That is like saying just because you can compile 1 as a double you should it should really be an int/short.