What is wrong?

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>

using namespace std;

char moveto;

void playgamez()
{
    cout<<"You are now standing on z. Were do you want to move?\n";
    cout<<"[q][w][e]\n[a][s][d]\n[0][x][c]\n";
    cin>> moveto;
    cin.get();
}







int main()
{
    char moveto;
    int array[3][3];

    cout<<"You are standing on 4. Were do you want to move?\n";
    cout<<"[q][w][e]\n[a][0][d]\n[z][x][c]\n";
    cin>> moveto;
    cin.get();

    switch ( moveto ) {
        case z:
         playgamez();
         break;
        case x:
         x();
         break;
        case c:
         c();
         break;
        case a:
         a();
         break;
        case s:
         s();
         break;
        case d:
         d();
         break;
        case q:
         q();
         break;
        case w:
         w();
         break;
        case e:
         e();
         break;

    }
}


When i try to compile this i get this error: error: 'z' was not declared in this scope. I get this error on line 32,35,38,41,44,47,50,53,56. Can anyone tell me what I have to change to get it to work?
z is a name of a variable (or would be if you had declared one). 'z' is a character.
ty :) , but I have fixed all of that now and now I can't build it (I'm using codeblocks)
you have global variable char moveto redeclared in int main
1
2
3
4
5
6
7
8
9
10
switch ( moveto ) {
        case 'z':
         playgamez();
         break;
        case 'x':
..........................
..........................
..........................
..........................
......etc // 


double declareation of
char moveto;
Last edited on
Post your new errors.
Topic archived. No new replies allowed.