I can't figure out how to fix this.

The problem is in 35, and 38. It says
error: ISO C++ forbids comparison between pointer and integer
This isn't the whole code, it's just some parts I picked. Thank you in advance!

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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 int main(){

menu();
return 0;

 }
int menu(){
    int menu1;
    char menu2;

    ClearScreen();
cout << "1.Play Game\n2.Guide\n3.Exit\n";
cin >> menu1;
switch (menu1){
case 1:
v11613();
break;
case 2:
cout << "This is an ASCII game, controlled with the muber pad.\n To move up press 8, to go down press right.\n The left and right movements are controlled by the 4 and 6 keys respectivly.\n";
cout << "\nThis is my first game, so please excuse the bugs that might be in it.\n I will be working on the code continuesly, so ask me or check on line for an update occasionally.\n thank you for playing my game!!\n";
cout << "\n for updates please check pogopogouk.blogspot.com";
cout << "\nPress the any key to continue\n";
cin >> menu2;
menu();
break;
case 3:
return 0;
};
}

int v13313(){
ClearScreen();
cout << "PPPPP__________________________Q\nPPPPPP_____________/ \__________\nPPPP_______________|b|__________\nPPPPP_______~~~~~_______________\nPPP________~~~~~~~______________\nPPP_______~~~~~~~~~_____________\nP__________~~~~~~~______/ \_____\nP___________~~~~~_______|a|_____\n________________________________\n____/ \_________________________\n____|c|_________________________\n________________________________\n________________________________";
cin >> inpt;
if (inpt == "e" || inpt == "E") {
cout << "Are you sure you want to exit?\ny/n";
cin >> inpt;
if (inpt == "y" || inpt == "Y")
return 0;}
else{
    input = ((int)inpt);
switch (input){
case 4:
v13213();
break;
case 6:
v13313a();
break;
default:
v13313();
break;
};
}
}

void v13313a(){
ClearScreen();
cout << "PPPPP__________________________Q\nPPPPPP_____________/ \__________\nPPPP_______________|b|__________\nPPPPP_______~~~~~_______________\nPPP________~~~~~~~______________\nPPP_______~~~~~~~~~_____________\nP__________~~~~~~~______/ \_____\nP___________~~~~~_______|a|_____\n________________________________\n____/ \_________________________\n____|c|_________________________\n________________________________\n________________________________";
cout << "sorry, that areas not available, i'm probably workig on it now.";
cin >> inpt;
if (inptkkjggnklfuklugspw21)
switch (input){
case 4:
v13213();
break;
case 6:
v13313a();
break;
default:
v13313();
break;
};
}

void v13213(){
ClearScreen();
cout << "PPPPP_________________________Q_\nPPPPPP_____________/ \__________\nPPPP_______________|b|__________\nPPPPP_______~~~~~_______________\nPPP________~~~~~~~______________\nPPP_______~~~~~~~~~_____________\nP__________~~~~~~~______/ \_____\nP___________~~~~~_______|a|_____\n________________________________\n____/ \_________________________\n____|c|_________________________\n________________________________\n________________________________";
cin >> inpt;
switch (input){
case 4:
v13113();
break;
case 6:
v13313();
break;
default:
v13213();
break;
};
}

void ClearScreen()
  {
  HANDLE                     hStdOut;
  CONSOLE_SCREEN_BUFFER_INFO csbi;
  DWORD                      count;
  DWORD                      cellCount;
  COORD                      homeCoords = { 0, 0 };

  hStdOut = GetStdHandle( STD_OUTPUT_HANDLE );
  if (hStdOut == INVALID_HANDLE_VALUE) return;

  /* Get the number of cells in the current buffer */
  if (!GetConsoleScreenBufferInfo( hStdOut, &csbi )) return;
  cellCount = csbi.dwSize.X *csbi.dwSize.Y;

  /* Fill the entire buffer with spaces */
  if (!FillConsoleOutputCharacter(
    hStdOut,
    (TCHAR) ' ',
    cellCount,
    homeCoords,
    &count
    )) return;

  /* Fill the entire buffer with the current colors and attributes */
  if (!FillConsoleOutputAttribute(
    hStdOut,
    csbi.wAttributes,
    cellCount,
    homeCoords,
    &count
    )) return;

  /* Move the cursor home */
  SetConsoleCursorPosition( hStdOut, homeCoords );
  }
Last edited on
easy fix in c and c++, chars are surrounded by just single quotes (' and ') and strings are surrounded by double qoutes (" and ")
Dear god. I can't even tell what this is supposed to be, let alone where inpt is defined.
1. Work on using proper indentation.
2. Here's a neat trick:
1
2
3
4
5
6
7
std::cout << "This text will "
             "span multiple lines "
             "in the code, but "
             "one line in the "
             "output unless you "
             "use the \n"
             "character, as shown.";

Also, why the weird function names?
Last edited on
its a game. i wasnt going to bother with syntax but i guess it would have been better to break the habit now do good call
We don't have a definition of inpt but it's a reasonable guess that it's a char and should be compared with character constants, such as 'y' or '1'

Just as the comparison with a string is not valid, this is not going to work:
1
2
3
input = ((int)inpt);
switch (input){
    case 4:

If the user enters '4', the casting to an integer value input will result in the ASCII character code of 52.

Better to just stick with
1
2
switch (inpt){
    case '4':
@Aramil thx, I didn't notice I had done that, I was copying and pasting a blank function, and filling in the blanks, so I figured it was ' not ".

@L B Aramil's right it's a game. The function names are coordinates, so v13313 is village 1 (33,13). And I've enver had problems with my indentation before, so >:P

@Chervil the numbers weren't the problem, but thx i'll do that next time to be safe.
Topic archived. No new replies allowed.