Find out the mistakes in the code

Hello everybody.
I am new in c++ and I made a little game. a labirent, a maze that ı created. You just give orders to walk in the direction of east, west, north or south. But there are some problems with the codes. Please can you help me to work it out.



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
62
63
64
65
66
67
68
69
70
71
#include <cstdlib>
#include <iostream>

using namespace std;

void walk(int x, int *p, int a[int i][int j]){
         
         
         switch(x){
                  case'1': p = &[i][j+1];if (*p=0){return p;}else cout<<"You hit your head to wall, try another direction"<<endl;break;
                  case'2': p = &[i][j-1];if (*p=0){return p;}else cout<<"You hit your head to wall, try another direction"<<endl;break;
                  case'3': p = &[i-1][j];if (*p=0){return p;}else cout<<"You hit your head to wall, try another direction"<<endl;break;
                  case'4': p = &[i+1][j];if (*p=0){return p;}else cout<<"You hit your head to wall, try another direction"<<endl;break;
                  default: cout<<endl<<"Not recognized. Enter it again: ";
                           Goto start;
                  }       
         
         
         }

main()
{
      
      system("color 0a");
      
      int a[10][10]={
      {0,1,0,1,0,0,0,0,0,0},
      {0,0,0,1,0,1,1,0,1,1},
      {0,1,1,1,0,1,0,0,1,0},
      {0,0,0,0,0,1,0,1,1,0},
      {0,1,1,0,1,1,0,0,0,0},
      {0,0,0,1,0,0,0,1,0,1},
      {0,1,1,1,0,1,1,1,0,0},
      {0,0,0,0,1,0,0,1,0,1},
      {0,1,1,1,1,0,1,0,0,1},
      {0,0,0,0,0,0,1,1,0,2}
      };
      
      
      
      for(int i=0;i<10;i++){for(int j=0;j<10;j++){      
      cout<<a[i][j]<<" "}
      cout<<endl;}

cout<<endl<<endl<<"0: Empty spaces, walkable paths  1: Walls 2: Exit    initial position: [0][0]"<<endl;
      
      int *coordinate;
      coordinate = &a[int x=0][int y=0];
            
      
      cout<<endl;
      
      
      int answer;
      cout<<endl<<"Enter the direction that you wanted to walk (1 for east, 2 for west, 3 for north, 4 for south): ";
      start:
      do {
          cout<<endl<<"actual position: ["<<x<<"]["<<y<<"]"<<endl;          
      cin>>answer;
      walk(answer, *coordinate, a[x][y]);
      }while(*coordinate!=2)
      
      
      cout<<endl<<endl<<endl<<"Congratz!! You are a free man now.."<<endl;
      
      
      

    system("PAUSE");
    return EXIT_SUCCESS;
}
Last edited on
= is assignment
== is comparison

Besides that, you've got a lot of syntax errors. Check out the tutorials.
Also
1
2
3
void foo(int bar){
  bar = 42;
}
is pointless
Topic archived. No new replies allowed.