scanf doesn't work in switch, which is itself in a while loop. I tried to find an answer in search already, but I didn't. So, if you know needed topic - write it please.
I'm trying to write code for a task in book, to make computer simulator "Simpletron", maybe somebody knows it.
while (memory[instructionCounter] != 4303)
{
//счетчик проходов по циклу
printf ("--> проход %d\n", instructionCounter);
instructionRegister = memory[instructionCounter];
operationCode = instructionRegister / 100;
operand = instructionRegister % 100;
//проверка операнда перед циклом
printf ("--> значение операнда перед циклом: %d\n", operationCode);
switch (operationCode)
{
case 10:
printf ("\n***\t" "Введите значение переменной:\t\t" "***\n");
scanf ("%d", &memory[operand]);
break;
case 20:
printf ("%d", memory[operand]);
break;
case 21:
printf ("***\t" "Симплетрон закончил вычисления.\t\t\t\t" "***\n");
break;
default:
printf ("***\t" "Симплетрон закончил вычисления.\t\t\t\t" "***\n");
break;
}
++instructionCounter;
}