-2
College exercises.
Guys, I decided to make a function so you don’t have to write the same code every time I want to know if the user will continue or not the program.
What happens is that it seems that every time the function returns as true and my code continues again.
That was the function I created
bool continuarCodigo (char escolha, bool continuar){
printf("Deseja continuar o programa? S/N");
scanf("%c", &escolha);
fflush(stdin);
while (escolha != 's' && escolha != 'S' && escolha != 'n' && escolha != 'N'){
printf("Opcao invalida, digite S/N");
scanf("%c", &escolha);
fflush(stdin);
}
if (escolha == 's' || escolha == 'S'){
continuar = true;
} else if (escolha == 'n' || escolha == 'N'){
continuar = false;
}
return continuar;
It even enters the last if to change the continue to false but the code continues the same way.
Add the code snippet that makes the call from that function, please.
– Andre
I’ve got it, thank you very much for your attention :)
– Paulox97