1
In case, I can not choose the option of the menu select difficulty, I am doing the switch correctly inside a switch?
#include <stdio.h>
#include <stdlib.h>
#define TENTF 5
#define TENTD 3
int main()
{
char opcao;
int nome;
printf("\n\t\t\t-------------------");
printf("\n\t\t\t JOGO DA FORCA");
printf("\n\t\t\t-------------------");
printf("\n\n\t\t\t1 - INICIAR PARTIDA");
printf("\n\t\t\t2 - CONFIGURAR DIFICULDADE");
printf("\n\t\t\t3 - SAIR");
printf("\n\n\t\t\tOPCAO DESEJADA:");
scanf("%c", &opcao);
switch (opcao)
{
case '1':
printf("\n\n\t\t\tINICIAR PARTIDA");
break;
case '2':
printf("\n\n\t\t\tCONFIGURAR DIFICULDADE");
printf("\n\n\t\t\t-------------------");
printf("\n\t\t\t JOGO DA FORCA");
printf("\n\t\t\t-------------------");
printf("\n\n\t\t\t F - FACIL");
printf("\n\n\t\t\t D - DIFICIL");
printf("\n\n\n\t\t\t V - VOLTAR");
printf("\n\n\t\t\tOPCAO DESEJADA:");
scanf("%c", &opcao);
break;
switch (opcao)
{
case 'F':
printf("\n\n\t\t\tCONFIGURAR DIFICULDADE");
printf("\n\t\t\t-------------------");
printf("\n\t\t\t JOGO DA FORCA");
printf("\n\t\t\t-------------------");
printf("\n\n\t\t\t F - FACIL*");
printf("\n\n\t\t\t D - DIFICIL");
printf("\n\n\n\t\t\t V - VOLTAR");
case 'D':
printf("\n\n\t\t\tCONFIGURAR DIFICULDADE");
printf("\n\t\t\t-------------------");
printf("\n\t\t\t JOGO DA FORCA");
printf("\n\t\t\t-------------------");
printf("\n\n\t\t\t F - FACIL");
printf("\n\n\t\t\t D - DIFICIL*");
printf("\n\n\n\t\t\t V - VOLTAR");
break;
case 'V':
printf("\n\t\t\t-------------------");
printf("\n\t\t\t JOGO DA FORCA");
printf("\n\t\t\t-------------------");
printf("\n\n\t\t\t1 - INICIAR PARTIDA");
printf("\n\t\t\t2 - CONFIGURAR DIFICULDADE");
printf("\n\t\t\t3 - SAIR");
printf("\n\n\t\t\tOPCAO DESEJADA:");
scanf("%c", &opcao);
break;
}
case '3':
printf("\n\n\t\t\tSAIR");
break;
default:
printf("\n\n\t\t\tDESCULPE, A OPCAO DIGITADA EH INVALIDA.");
printf("\n\n\t\t\tOPCAO DESEJADA:");
scanf("%c", &opcao);
break;
}
}
same thing, had already tried so...I did with if , It even, but it did not work
– Insane
Boy, check it out right there, 'cause I really don’t see why it doesn’t work that way here. Take all these printf, put something cleaner just to test.
– Raylan Soares
Have you tried declaring another variable to capture the second option instead of using it?
– Deise Vicentin