I made the code below to read simple date information, but when it reads the day, it oddly asks for two entries, and ends up going one for the variable diatemp and the other for the diatemp > mestemp , without calling printf ("Type the month"), this ends up making it impossible to continue the program, does anyone have any suggestions 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();
}