Ascii list

This is a discussion on Ascii list within the C++ Programming forums, part of the General Programming Boards category; I wrote a simple program to display ASCII code but when I run it, some of the ASCII stuffs up ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    7

    Ascii list

    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
    Attached Images Attached Images  

  2. #2
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    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

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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.

  4. #4
    Registered User
    Join Date
    Sep 2009
    Posts
    7
    lol thanks, no wonder... so it's actually meant to 'screw' up and appear like that!

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,401
    Quote Originally Posted by quzah
    The beep is \b typically, and IIRC, it's 8.
    I thought that \b was for backspace, and \a was for alert, the latter typically resulting in a beep.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    That's it. Been a long time since I've needed either.

    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    Quote Originally Posted by C++ student View Post
    lol thanks, no wonder... so it's actually meant to 'screw' up and appear like that!
    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;
    }

  8. #8
    Registered User
    Join Date
    Sep 2009
    Posts
    7
    thanks for the code sebastiani, i'll try investigating it :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. instantiated from here: errors...
    By advocation in forum C++ Programming
    Replies: 5
    Last Post: 03-27-2005, 08:01 AM
  3. How can I traverse a huffman tree
    By carrja99 in forum C++ Programming
    Replies: 3
    Last Post: 04-28-2003, 05:46 PM
  4. List class
    By SilasP in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2002, 04:20 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21