Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Hangman C++ code with so much errors. Please help, (http://www.go4expert.com/forums/hangman-cpp-code-errors-help-t21259/)

Serenity1194 9Mar2010 10:41

Hangman C++ code with so much errors. Please help,
 
Code:

#include<iostream>
#include<ctime>
#include<cctype>


const char dictionary [4][3][60] = {
                                        {"similarity", "advertiser", "bookkeeper"},
                                        {"encyclopedia", "transportation", "establishments"},
                                        {"sedimentation", "acquirement", "procurement"},
                                        {"zenzizenzizenzic", "antidisestablishmentarianism", "pneumonoultramicroscopicsilicovolcaniosis"}
                                    };
                                   
#define char cheat = "Crepe";
bool cheat_check = false, start_screen = true, guess;
int error_ctr = 0, diff_set, lim;
char store_array [60], out_array [60], name[20];
char ans, user_inp;


void GameMaster();
void Drawing(bool);
int RandNumGen();
void Environment(int);
void Input();
void Dictionary(int, char []);
bool GuessChecker ();

int main();
{
    int env_num;
    Drawing(start_screen);
    start_screen = false;
    system("pause");
    system("cls");
    GameMaster();
    env_num = RandNumGen();
    Environment(env_num);
    system("pause");
    return 0;
}

void GameMaster()
{
    cout<<"Welcome to Foot Noose, where we (ironically) hang you by the head, not the foot!"<<endl;
    cout<<"Now, how shall I call you?"<<endl;
    cin>>name;
    if (strcmp(name, "Crepe")==0)
    {
        cout<<"Excellent! Don't we all know that Crepe is tasty?"<<endl;
        system("cls");
        cheat_check = true;
    }
    cout<<"Hello, "<<name<<endl;
    system("cls");

    char difficulty;

    cout<<"The rules of Foot Noose are simple. The computer will pick a word, "<<endl<<"and you have a set number of tries to guess the word."<<endl;
    cout<<"You have to do this one letter at a time."<<endl<<endl;
    cout<<"There are four difficulty settings with which to play the game."<<endl;
    cout<<"Easy is a set of words with minimal complication, and lots of repeating letters."<<endl<<" So if you get the repeating letter correctly,"
        <<" you've taken a large part of the word."<<endl;
    cout<<"Medium is a step up from easy, with bigger words. No worries, because they're not that hard to guess."<<endl;
    cout<<"Hard is a good few steps from Medium, so as to live up to its name."<<endl<<" Scientific terms present in this difficulty."<<endl;
    cout<<"Extreme is a far cry from hard. If you get the word here, you must be really lucky, or really smart."<<endl<<" It wasn't named Extreme"
        <<" for nothing."<<endl;
    system("cls");
    cout<<"(E) for Easy, (M) for Medium, (H) for Hard, (X) for Extreme."<<endl;
    cout<<"How far will you dig your grave? Or for those who do not understand metaphors,"<<endl<<"What difficulty would you want?"<<endl;
    cin>>ans;

    switch (ans)
    {
        case 'E':
        case 'e':
            {
                diff_set = 1;
                lim = 4;
                break;
            }
        case 'M':
        case 'm':
            {
                diff_set = 2;
                lim = 6;
                break;
            }
        case 'H':
        case 'h':
            {
                diff_set = 3;
                lim = 9;
                break;
            }
        case 'X':
        case 'x':
            {
                diff_set = 4;
                lim = 12;
                break;
            }

    }

    Dictionary(diff_set, store_array []);

SavePoint1:

    Input();

    guess = GuessChecker();

    if (!guess)
    {
        error_ctr++;
        Drawing(start_screen);
        if (error_ctr < lim)
            goto SavePoint1;
    }
    else if (error_ctr == lim)
        Drawing(start_screen);   
    else
    {
        if (strcmp(store_array, out_array)==0)
            break;
        else
            goto SavePoint1;
    }
}

void Dictionary(diff, store [])
{
    int num1 = RandNumGen();
    for (int ctr = 0; dictionary[diff][num1][ctr]; ctr++)
        store[ctr] = dictionary[diff][num1][ctr];
}

void Input()
{
    char temp;

    cout<<"Now, choose one of the 26 letters of the alphabet."
    cin>>user_inp;

    while (!(isalpha(user_inp)))
    {
        cout<<"Not that letter. The letter which is actually part of our alphabet."<<endl;
        cin>>user_inp;
    }

    if (isupper(user_inp))
        temp = tolower(user_inp);

    user_inp = temp;
}

void Drawing(bool screen)
{
    int wid_len;
    wid_len = lim - error_ctr;
    if (screen)
    {
        cout<<" _______ _______ _______ _______    _______ _______ _______ _______ _______ "<<endl;
        cout<<"|\    /|\    /|\    /|\    /|  |\    /|\    /|\    /|\    /|\    /|"<<endl;
        cout<<"| +---+ | +---+ | +---+ | +---+ |  | +---+ | +---+ | +---+ | +---+ | +---+ |"<<endl;
        cout<<"| |  | | |  | | |  | | |  | |  | |  | | |  | | |  | | |  | | |  | |"<<endl;
        cout<<"| |F  | | |O  | | |O  | | |T  | |  | |N  | | |O  | | |O  | | |S  | | |E  | |"<<endl;
        cout<<"| +---+ | +---+ | +---+ | +---+ |  | +---+ | +---+ | +---+ | +---+ | +---+ |"<<endl;
        cout<<"|/_____\|/_____\|/_____\|/_____\|  |/_____\|/_____\|/_____\|/_____\|/_____\|"<<endl;
    }
    else if (error_ctr < lim)
    {
        cout<<" _____  "<<setw(wid_len)<<" ___ "<<endl;
        cout<<"|    |  "<<setw(wid_len)<<" | | "<<endl;
        cout<<"|        "<<setw(wid_len)<<"====="<<endl;
        cout<<"|        "<<setw(wid_len)<<"(>_<)"<<endl;
        cout<<"|        "<<setw(wid_len)<<" /|\\ "<<endl;
        cout<<"|_______ "<<setw(wid_len)<<"o | o"<<endl;
        cout<<"_______/|"<<setw(wid_len)<<" / \\ "<<endl;
        cout<<"|      | "<<setw(wid_len)<<"/  \\"<<endl;
        Sleep(1000);
        system("cls");
    }
    else if (error_ctr == lim)
    {
        cout<<" _____                            "<<endl;
        cout<<"|    |                            "<<endl;
        cout<<"|    0                            "<<endl;
        cout<<"|    /|\\                        "<<endl;
        cout<<"|    / \\                        "<<endl;
        cout<<"|_______                            "<<endl;
        cout<<"_______/|                        "<<endl;
        cout<<"|      |                            "<<endl;
        cout<<"                                    "<<endl;
        cout<<"@@@@@@@@  @@@@@@  @@@  @@@    "<<endl;
        cout<<"@@@@@@@@  @@@@@@@@  @@@  @@@    "<<endl;
        cout<<"@@!      @@!  @@@  @@!  @@!    "<<endl;
        cout<<"!@!      !@!  @!@  !@!  !@!    "<<endl;
        cout<<"@!!!:!    @!@!@!@!  !!@  @!!    "<<endl;
        cout<<"!!!!!:    !!!@!!!!  !!!  !!!    "<<endl;
        cout<<"!!:      !!:  !!!  !!:  !!:    "<<endl;
        cout<<":!:      :!:  !:!  :!:  :!:    "<<endl;
        cout<<" ::      ::  :::  ::  :: ::::"<<endl;
        cout<<" :        :  : :  :    : :: : :"<<endl;
        system("pause");
        system("cls");
    }
}

bool GuessChecker()
{
    int true_check = 0;
    for (int ctr = 0; store_array[ctr]; ctr++)
    {
        if (store_array[ctr] == user_inp)
        {
            out_array[ctr] = store_array[ctr];
            true_check++;
        }
    }

    if (true_check > 0)
        return true;
    else
        return false;
}


xpi0t0s 9Mar2010 13:02

Re: Hangman C++ code with so much errors. Please help,
 
What errors?

Serenity1194 9Mar2010 13:07

Re: Hangman C++ code with so much errors. Please help,
 
Ahh, I have fixed the problem. There was a semi-colon in main. There was also a function that I forgot to put. It's all good now. Thanks though.


All times are GMT +5.5. The time now is 17:21.