I wrote a simple program to display ASCII code but when I run it, some of the ASCII stuffs up and my computer makes a loud beep, does anyone know why?
thanks
Printable View
I wrote a simple program to display ASCII code but when I run it, some of the ASCII stuffs up and my computer makes a loud beep, does anyone know why?
thanks
Certain characters, when printed, cause a beeping sound (beep chars). I'd imagine those music lyric icons do.
Beep beep!
I'm sure there's some historical reason for this. However I'm more interested in how to easily disable it, other than filtering strings of course.
The beep is \b typically, and IIRC, it's 8. The music notes are just characters, not sounds. 10 is \n, 13 is \r. You might take a look at asciitable.com
Quzah.
lol thanks, no wonder... so it's actually meant to 'screw' up and appear like that!
I thought that \b was for backspace, and \a was for alert, the latter typically resulting in a beep.Quote:
Originally Posted by quzah
That's it. Been a long time since I've needed either.
Quzah.
It might be a good idea to filter out all non-printable, non-space characters. For one thing, their appearance on the display isn't really ASCII, but whatever the OS and current code-page maps them to. For another, they can obviously lead to some weird effects (such as the one you encountered). I'd recommend something like this:
Code:#include <iostream>
#include <iomanip>
int main( void )
{
using namespace
std;
for( int ch = 0; ch < 128; ++ch )
{
cout << setw( 3 ) << dec << ch << " : ";
if( isprint( ch ) && !isspace( ch ) )
cout << "'" << char( ch ) << "'";
else
cout << "0x" << hex << ch;
cout << endl;
}
return 0;
}
thanks for the code sebastiani, i'll try investigating it :P