Slightly more C++ oriented but...

can somebody PLEASE tell me why this is giving me illegal break, and illegal default errors??!!!


switch(key)
		case 'w': shipAcc_y =+ 0.1;
				printf("
----- Up pressed.




 shipAcc_y = %d 	", shipAcc_y);
				break;
		default: printf("key not vaild");

You’re missing ‘{’ and ‘}’ around the body of your switch statement.

thank you that sorted the switch problem.
However i’m looking at the way the variable shown within (shipAcc_y) incriments. And in the console window, it’s showing that whenever I press the w key the variable changes to -1610612736.
Can you tell what i’m doing wrong?

Note: shipAcc_y is defined in the global scope as i use it in my display loop later on in order to make a ship move. (I’m trying to create a space ship that accelerates and decelerates in given directions)

I think %d in the printf statement is meant for integer numbers. You could try %f to print the value.

it worked thanks