My professor was explaining how in C you can assign an 8 bit Char to an Int (in this case a 32 bit int). He showed us by creating int x set to the value of 'a' and then printing x+1 to display "b"
So i figured I would just try it out and print a through z to the console. I incorrectly made my for loop and didn't really notice until my ears were met with this terrible beeping sound coming from my motherboard during debug. I know it was my mobo because my volume was muted
Needless to say the entire class stopped and stared at me while I was trying to stop the debugging lol,
Anyways here is the code:
#include <stdio.h>
void main (void)
{
int x = 'a', y = 0;
for (y; y < 26; x += 1)
putchar(x);
}
I ran this code on my desktop and I recieved the same beeps, luckily though my mobo speakers are more forgiving than my Dell Latitude D630 which sounded more like a siren...
I understand that this loop would not produce the result I wanted simply because I never increment y, but what I still cannot figure out is why it causes my motherboard to beep? I was wondering if any of you guys might know why this happens, I am genuinely curious because I have never had an experience like this before.
Here is the code that produces the correct results, note the loop:
#include <stdio.h>
void main (void)
{
int x = 'a', y = 0;
for (y; y < 26; y++)
putchar(x + y);
}
EDIT: I am using VS2010 runtime environment
- Vex
Edited by Vexatus_Boi, 30 January 2012 - 02:32 AM.

















