define# switch case

Non-platform specific questions.

define# switch case

Postby jazz_e_bob » Sat Mar 17, 2007 9:12 am

I've defined some stuff in global code:

Code: Select all
#define E 0;
#define N 90;
#define W 180;
#define S 270;


but when I try the code...

Code: Select all
switch ( creator.myDirection )
{
    case E: xvelocity = mySpeed; break;
    case N: yvelocity = -mySpeed; break;
    case W: xvelocity = -mySpeed; break;
    case S: yvelocity = mySpeed; break;
}


The compiler expects a ":" on the case lines.

Any feedback appreciated.
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby makslane » Sat Mar 17, 2007 2:01 pm

Remove the ; in the defines.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby jazz_e_bob » Sat Mar 17, 2007 6:54 pm

:oops:

Thanks mate.
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest