0
Person, what would be the best structure to force the user to enter positive integers within an array (array), the code fragment I copied here is inside a function, it works ok when first executed, however if I call it again at another time, the system does not consider the entered value, but rather that of the position of i. for example
int consumidor[50];
int i = 0, continuar = 1;
while (continuar = 1){
while (consumidor[i] < 1)
{
printf("Insira o código do consumidor a ser cadastrado: ");
scanf_s("%d", &consumidor[i]);
if (consumidor[i] < 1) {
printf("Digite um código superior a '0'.\n");
}
i++;
printf("Deseja inserir um novo consumidor? Digite '1' para sim ou tecle qualquer outra tecla para sair. ");
scanf_s("%d", &continuar);
}