Jump to content


- - - - -

Interesting Debug


3 replies to this topic

#1 Vexatus_Boi

    C - P = S - X + i - d

  • Members
  • PipPipPipPipPip
  • 407 posts
  • Gender:Male
  • Location:USA
  • Interests:Computers, Gaming, Photoshop
  • Clan:Boi

Posted 30 January 2012 - 02:30 AM

I was in class the other day and had one of the most embarrassing things ever happen to me.

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.

Posted Image
Posted Image Beware the beast but enjoy the feast he offers.

Antec Twelve Hundread Gaming Case
Asus M4A785TD-V EVO
AMD Phenom II x4 955 Deneb BE 3.2 GHz
G.Skill Ripjaws 16 GB DDR3 1333 (PC3 10666)
EVGA Geforce 560 Ti Fermi
Corsair H60 Water Cooler
x2 Seagate Barracuda 1TB 7200 RPM
Corsair HX 850W PSU

#2 ZonFire99

    Hero Editor guy

  • Admin
  • 6,700 posts
  • Gender:Male
  • Location:Toronto, Canada
  • Battle.Net Tag:ZonFire99#1500
  • Clan:FBI

Posted 07 February 2012 - 10:21 AM

The ASCII character value of 7 is a bell (beep sound). Your initial code will keep counting up, but will evetually overflow, and essentially start at 0 again. Each cycle it will output a beep. :)
Posted Image
Thanks to Lloyd for the Signature.

#3 Vexatus_Boi

    C - P = S - X + i - d

  • Members
  • PipPipPipPipPip
  • 407 posts
  • Gender:Male
  • Location:USA
  • Interests:Computers, Gaming, Photoshop
  • Clan:Boi

Posted 18 February 2012 - 02:24 PM

Just the man I wanted to hear from! That definitely explains it lol, I had no idea 7 was the beep! I had a feeling it was overflowing but I didn't realize it would go back to 0, that property could come in handy later!
Posted Image
Posted Image Beware the beast but enjoy the feast he offers.

Antec Twelve Hundread Gaming Case
Asus M4A785TD-V EVO
AMD Phenom II x4 955 Deneb BE 3.2 GHz
G.Skill Ripjaws 16 GB DDR3 1333 (PC3 10666)
EVGA Geforce 560 Ti Fermi
Corsair H60 Water Cooler
x2 Seagate Barracuda 1TB 7200 RPM
Corsair HX 850W PSU

#4 Sheer_Cold

    Imperial Knight of Ladder Hall

  • Retired Staff
  • PipPipPipPipPipPipPip
  • 1,142 posts
  • Gender:Male
  • Location:Wisconsin

Posted 02 March 2012 - 12:58 PM

Tried in Visual C++. It returned pretty much the entire character map with a constant looping beep. Must've been quite embarrasing for you, haha!
Posted Image
Old PDM Archive
SCMod 1.02b (v1.11b)
Perfect Drop Mod 1.05 (v1.13c) - Download
Perfect Drop Mod 1.06 (v1.13c) - Download
Perfect Drop Mod 1.06b (v1.13c) - Download | Change Log (Rel. Oct 28, 2011)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users