there's an error

what will i do if there is an error like this?

In function `int main()':
jump to case label
crosses initialization of `int hop'
crosses initialization of `int hip'
put your case body in its own scope by adding {braces}

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
// old

switch( foo )
{
case bar:
  int hop = 5;
  break;

case baz:
  break;
}


// new

switch( foo )
{
case bar:
  {
    int hop = 5;
  }
  break;

case baz:
  break;
}

that's my program..can you help me fix the errors please?
it should be when user enters d ,the program ends..please help
Last edited on
The problem is in
case 'C':
case 'c':

int hip=0;
int hop=1;

kindly rectify it as :
case 'C':
case 'c':
{
int hip=0;
int hop=1;
..
..
}
still it doesnt stop when i entered d:((
while(choices!='D' || 'd');

This is not equivalent to choices != 'D' || choices != 'd', and will always evaluate to true. Were it equivalent, it still wouldn't be what you intended.

while ( !(choices == 'D' || choices == 'd') );

Last edited on
Topic archived. No new replies allowed.