Sto provando a creare una funzione che comporterà printf
una determinata stringa se l'utente preme un tasto qualsiasi sulla tastiera TRANNE per capitale P
, se l'utente preme P
allora si interromperà il cappio.Come utilizzare kbhit e getch (programmazione C)
Tuttavia, non penso di utilizzare _kbhit
e _getch
correttamente. Io uso il numero 80 perché è il simbolo ASCII per 80 .... mi dispiace per la confusione
void activateAlarm(int channelID) {
int key = 0;
while(temperatureChannel[channelID].currentTemperature > temperatureChannel[channelID].highLimit
||temperatureChannel[channelID].currentTemperature < temperatureChannel[channelID].lowLimit) {
beep(350,100);
if (_kbhit()) {
key = _getch();
if(key == 'P');
break;
}
}
}
'se (== chiave 'P'); break; 'dovrebbe preferibilmente essere 'if (key ==' P ') break;' – moooeeeep