Why isn't this working?

I have a namecheck:
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
31
32
33
34
void namecheck()
{
    ifstream namefile;
    fileName = name;
    fileName += ".txt";

    namefile.open(fileName.c_str());
    if (namefile.is_open())
    {
        namerejectprint();
        getInfo();
        getline (cin, account);
        if (account.compare(password) == 0)
        {
            cout << "Account found" << endl;
            cout << "Loading saved data..." << endl;
            q=3;
            pass=0;
            spec=0;
            rac=0;
            rol=0;
            nam=0;
        }
        if (account.compare(password) != 0)
        {
            cout << "Sorry, that is incorrect" << endl;
        }
    }
    else
    {
        nameapproveprint();
        c=0;
    }
}


and I have a character creation sequence:
1
2
3
4
5
6
7
8
9
10
11
12
13
void charactercreation()
{
    while (q==1)
    {
        overallname();
        overallpassword();
        overallrace();
        overallclass();
        overallroll();
        accountadd();
        q=2;
    }
}


and this is my int main:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
int main()
{
    charactercreation();
    if (q==2)
    {
        loreprint();
        printToBuffer();
        printPlayer();
        printBuffer();
        storyline1print();
        commands();
    }
    if (q==3)
    {
        getInfo();
        printToBuffer();
        printPlayer();
        printBuffer();
        commands();
    }
    return 0;
}


What it's supposed to do is log someone in if they have an account. Instead, it continues with all of the functions as if q didn't equal three and instead equaled 2. Could someone help?
This is difficult to help with without having for information (namely, the code for all those other functions) but to give all the code would be unwieldy and almost as difficult to help with.

I would highly suggest using a debugger to step through the code and see what the values of variables (namely q) are at certain points and what the path of execution is. How are you writing your code? If you're using an IDE, it probably has a built-in debugger that could be very helpful here.
Topic archived. No new replies allowed.