Hi all. This isn't exactly an OS question and more of a C question in general. I have some code that goes
Code:
unsigned char getKey() {
return 0;
}
while(1) {
unsigned char key = getKey();
if(key > 0) {
printByte(key);
}
}
This should always do nothing, correct? yet on qemu and bochs it will print out 20h occasionally for no apparent reason. I added a part to my getKey() that assigns, reassigns and then trashes a variable, and that seems to get rid of the problem on qemu, but not bochs. Is there something "under the hood" that I'm missing?
(If you want to peek for yourself, my signature has a link to my github. set the first line of the getKey() function in ioutils.c to be return 0 and it'll do it)