Ok, i know my program is probably all done incorrectly and thier are probably eaiser ways but, it works for me so.. I have an error and i cant find out what it is. Can anyone tell me?

//Game Project 1

#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
#include <stdlib.h>

main()
{
    char weapon, head, chest, hands, legs, feet, name[21];
    int health, money, answer, shop_answer, fight_answer, weapon_answer; 
    int armor_answer, potion_answer;
    health = 100;
    money  = 0;
    
    cout<<setw(40)<<"BLANK"<<endl;
    getch();
    system("CLS");                   //Clears the Screen
    cout<<"Enter a name: ";
    cin.get(name, 21);
    cin.ignore(30,'\n');
    system("CLS");                   //Clears the Screen   
{
    do   
{   
    system("CLS");                   //Clears the Screen
    cout<<setw(30)<<"---------"<<name<<"---------"<<endl;
    cout<<"\n";
    cout<<"---WEAPON---    "<<endl;
    cout<<"Weapon  =  "<<weapon<<endl;
    cout<<"\n";
    cout<<"---ARMOR---     "<<endl;
    cout<<"Head   =  "<<head<<endl;
    cout<<"Chest  =  "<<chest<<endl;
    cout<<"Hands  =  "<<hands<<endl;
    cout<<"Legs   =  "<<legs<<endl;
    cout<<"Feet   =  "<<feet<<endl;
    cout<<"\n";
    cout<<"---ITEMS---"<<endl;
    cout<<"Health    "<<health<<endl;
    cout<<"Money     $"<<money<<endl; 
    getch();      
    
    system("CLS");                   //Clears the Screen
    cout<<"---What would you like to do?---\n"<<endl;
    cout<<"1) Shop\n";
    cout<<"2) Fight\n";
    cout<<"3) See Stats\n";
    cout<<"Press 1, 2, or 3:\n ";
    cin>> answer;
    switch (answer)
    {
        case 1:
        system("CLS");                   //Clears the Screen
        cout<<"---What would you like to buy?---\n";
        cout<<"1) Weapons\n";
        cout<<"2) Armor\n";
        cout<<"3) Health Potions\n";
        cout<<"Press 1, 2, or 3:\n ";
        cin>> shop_answer;
        
        case 2:
        system("CLS");                   //Clears the Screen
        cout<<"---Who do you want to fight?---\n";
        cout<<"1) A Man\n";
        cout<<"2) A Bandit\n";
        cout<<"3) A Knight\n";
        cout<<"4) A Dragon\n";
        cout<<"Press 1, 2, 3, or 4:\n ";
        cin>> fight_answer;        
        switch (shop_answer)
        {
            case 1:
                system("CLS");                   //Clears the Screen
                cout<<"---What type of Weapon do you want to buy?---\n";
                cout<<"1) Sword\n";
                cout<<"2) Bow\n";
                cout<<"3) Mace\n";
                cout<<"Press 1, 2, or 3:\n ";
                cin>> weapon_answer;
                
            case 2:
                system("CLS");                   //Clears the Screen
                cout<<"---For what part of body?---\n";
                cout<<"1) Head\n";                   
                cout<<"2) Chest\n";
                cout<<"3) Hands\n";
                cout<<"4) Legs\n";
                cout<<"5) Feet\n";
                cout<<"Press 1, 2, 3, 4, or 5:\n ";
                cin>> armor_answer;
                
            case 3:
                system("CLS");                   //Clears the Screen
                cout<<"---One potion costs 25 gold. are you sure you want to buy?\n";
                cout<<"1) Yes\n";
                cout<<"2) No\n";
                cout<<"Press 1 or 2:\n ";
                cin>> potion_answer;                
                switch (potion_answer)
                {
                    case 2:
                    answer = 3;
     ////////SPACE////////////SPACE//////////////SPACE////////////SPACE///////////      
                if ((potion_answer == 1) && (money >= 25))
                {
                    health = health - 20;
                    money = money - 25;
                    answer = 3;
                    {
                if ((potion_answer == 1) && (!(money >= 25))) 
                        { 
                        cout<<"You do not have enough money!\n";
                        answer = 3;
                    
}                                                 
}while (answer == 3);                   //Loop again if answer is equal to 3.
}    
getch();
return 0;
}

From a quick glance, I'd guess it might be related to the missing breaks for each case. Would you mind describing the error?

I dont think its the breaks because i didnt have them in before. There is an error that says "syntax error at end of input" I was thinking it had to do something with { or } somewhere. But ill keep looking and trying stuff out.

Uh, yeah. You have 9 opening braces { and 4 closing braces }. They need to be equal in number. Now is a good time to learn to match them up using proper indentation.

ok thanks ill try that out

yeah it worked thanks a lot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.