I'm doing a contact list, but I'm having problems with using gets() in visual studio. The code below is inside a switch statement.
if (nome[i][0] == 0 && numero[i] == 0){
printf("Nome:\n");
fflush(stdin);
gets(nome[i]);
printf("Numero:\n");
scanf("%d", &numero[i]);
}
The problem that I'm having is that the gets() is skipped, but if I put a scanf("%c", &c) before the gets() like this it works.
if (nome[i][0] == 0 && numero[i] == 0){
printf("Nome:\n");
fflush(stdin);
scanf("%c", &c);
gets(nome[i]);
printf("Numero:\n");
scanf("%d", &numero[i]);
}
Someone told me that the problem causing this is a known problem with the visual studio console and there is a fix, but I can't find anything related to it on the internet. If someone told me what to do to fix it it would be really helpfull. If I put the first code in another IDE it works.