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
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.
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
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.
Hope is the first step on the road to disappointment.
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.Originally Posted by quzah
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
That's it. Been a long time since I've needed either.
Quzah.
Hope is the first step on the road to disappointment.
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