Thread: alert beep sound

  1. #1
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252

    alert beep sound

    hey guys does anyone know why this code will not make a sound alert im compiling it in ansi c using linux?

    Code:
    #include <stdlib.h>
    #include <stdio.h>
    
    int main (void)
    {
    
       char beep = '\007';
       
       printf("%c", beep);
    
        return EXIT_SUCCESS;
    }

  2. #2
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Most likely because your terminal isn't setup/configured to beep when it receives the ASCII BEL character.

    By the way, you should use '\a' for a beep, it doesn't assume ASCII and isn't a magic number.

  3. #3
    C/C++Newbie Antigloss's Avatar
    Join Date
    May 2005
    Posts
    216
    The alert character (\a), added by C90, produces an audible or visible alert. The nature of the alert depends on the hardware, with the beep being the most common. (With some systems, the alert character has no effect.)

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    added by C90
    Do you mean C89?

    im compiling it in ansi c using linux
    My Linux terminal doesn't beep by default, either. DOS does. You'll have to configue your terminal if you really want to have your ears blasted away.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Low latency sound effects
    By VirtualAce in forum Game Programming
    Replies: 0
    Last Post: 12-21-2004, 01:58 AM
  2. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  3. Producing Beep Sound with C++
    By ron4ldk in forum C++ Programming
    Replies: 8
    Last Post: 05-01-2004, 01:05 AM
  4. DirectSound - multiple sounds
    By Magos in forum Game Programming
    Replies: 9
    Last Post: 03-03-2004, 04:33 PM
  5. sounds?
    By BODYBUILDNERD in forum C++ Programming
    Replies: 6
    Last Post: 12-06-2002, 03:34 PM