Saturday, May 22, 2010

Can someone check my c code please? Will not run?

Thankyou!





void select_shape(void)


{


int key_entered;


key_entered=getch();





do


{


switch (key_entered)


{


case 1:


outtextxy(300, 300, "1. Square");


break;





case 2:


outtextxy(300, 300, "2. Rectangle");


break;





case 3:


outtextxy(300, 300, "3. Triangle");


break;





case 4:


outtextxy(300, 300, "4. Cricle");


break;


};


}


while (key_entered != 13);





}

Can someone check my c code please? Will not run?
It would be useful to know "how it doesn't run" and how you are trying to run it.





By the way, the key_entered=getch(); needs to be inside the do, otherwise you will have an infinite loop.
Reply:as someone else has already mentioned you have getch outside do and you have an addition semi colan after the } that terminates the switch.
Reply:you have added one more } at





}


while (key_entered != 13);


No comments:

Post a Comment