0
I made the code below to read simple date information, but when it reads the day, it strangely asks for two entries, and ends up going one to the variable diatemp and the other to the mestemp, without calling the printf("Type the month"), this ends up making it impossible to continue the program, someone has some suggestion of what I could do to solve this problem?
void PegarDadosIniciais(){
//Data dataAtual;
int diatemp, mestemp, anotemp;
printf(" @----------------------------------------------------------------------------@\n");
printf(" | ");printf("\t\t\t SISTEMA DE LOCACAO DE VEICULOS");printf("\t\t |\n");
printf(" @----------------------------------------------------------------------------@\n");
printf("\n");
printf("Bem vindo ao sistema de locacoes de veiculos!! \n");
printf("%s\n","Precisaremos de alguns dados para iniciar o sistema.." );
printf("%s\n\n","PRESSIONE ENTER PARA CONTINUAR.." );
getch();
system("cls");
printf(" @----------------------------------------------------------------------------@\n");
printf(" | ");printf("\t\t\t CONFIGURACOES INICIAIS");printf("\t\t |\n");
printf(" @----------------------------------------------------------------------------@\n");
printf("\n");
printf("%s\n",">>INSIRA A DATA ATUAL<<" );
printf("%s", "Insira o dia: " );
scanf("%d\n", &diatemp);
printf("%s\n","Insira o mes: " );
scanf("%d\n", &mestemp);
printf("%s\n","Insira o ano: " );
scanf("%d\n", &anotemp);
printf("%d/%d/%d",diatemp, mestemp, anotemp);
getch();
}
Probably taking the keyboard buffer, puts another
getch()
or usesystem("pause")
– Brumazzi DB