This is the code:
while (op != 0) {
op = 0;
scanf_s("%i", &op);
system("cls");
printf("\n\n");
switch (op) {
case 1:
printf("Ingrese el numero de cedula del cliente y presione enter: \n");
scanf_s("%i", &numCedula);
if (numCedula <= 99999999 && numCedula > 0) {
invertirNumero(numCedula);
resultDigito = sumaDigitos(numCedula);
printf("La suma de los digitos es: %i \n", resultDigito);
i++;
arreglo[i] = resultDigito;
break;
}
else {
printf("el numero de cedula no puede exceder los 8 digitos \n tiene que ser positivo \n distinto de cero \n y no puede contener letras ni puntos");
break;
}
case 2:
ordenar(arreglo);
break;
}
if (op) {
printf("\n\n");
system("pause");
system("cls");
}
}
return 0;
}
I think it is something related to the scan that is after the while the cycle prints on the screen and then remains in infinite loop, the main problem is when the option chosen is 1 and the scanf_S of numCedula takes a value that is not a integer