Guys i need your help. I want to make code about this : printf("MAIN MENU\n"); printf("[d] Display Empty Chess Board\n"); printf("[v] Check Validity of Chess Notation\n"); printf(" Save Moves to a Text File\n"); printf("[f] Find Chess Moves in a String\n"); printf("[e] End Program\n"); If the user select one of the correct characters (d,v,s,f) the programm is being executed. If the user select e, the programm will be terminated
Create a new variable of character data type say choice and switch it, like printf("...............all the above content of yours) scanf("Enter the choice %c",&choice); switch(choice) { case 'd': Your program code case 'v': Your program code case 's': Your program code case 'f': Your program code case 'e':break; } This should work!!!
Your code was correct but you should write it as switch(choice) { case 'd': Your program code break; //here you should use break statement otherwise if user give input as 'd' then all the code present under 'v','s','f','e' will also execute so better to use break statement after each case in your switch
have you any idea about showing a chess. What about the following? Code: switch(select) { case 'd': /* if you choose d*/ for(i=8;i>0;i--) { printf("%d %c %c %c %c \n",i,219,219,219,219); } printf(" abcdefgh\n"); system(“pause”); } break;