BEEP function

This is a discussion on BEEP function within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream> #include <windows.h> #include <iomanip> using namespace std; void a(); void b(); void c(); void d(); void e(); ...

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    40

    BEEP function

    Code:
    #include <iostream>
    #include <windows.h>
    #include <iomanip>
    
    
    using namespace std;
    
    
    void a();
    void b();
    void c();
    void d();
    void e();
    void f();
    void g();
    void h();
    void i();
    void j();
    void k();
    void l();
    void m();
    void n();
    void o();
    void p();
    void q();
    void r();
    void s();
    void t();
    void u();
    void v();
    void w();
    void x();
    void y();
    void z();
    
    
    
    
    int main()
    {
        h();
        e();
        l();
        l();
        o();
        return 0;
    }
    
    
    
    
    void a()
    {
    Beep(700, 200);
    Beep(700, 600);
    }
    
    
    void b()
    {
    Beep(700, 600);
    Beep(700, 200);
    Beep(700, 200);
    Beep(700, 200);
    }
    
    
    void c()
    {
    Beep(700, 600);
    Beep(700, 200);
    Beep(700, 600);
    Beep(700, 200);
    }
    
    
    void d()
    {
    Beep(700, 600);
    Beep(700, 200);
    Beep(700, 200);
    }
    
    
    void e()
    {
    Beep(700, 200);
    }
    
    
    void f()
    {
    Beep(700, 200);
    Beep(700, 200);
    Beep(700, 600);
    Beep(700, 200);
    }
    
    
    void g()
    {
    Beep(700, 600);
    Beep(700, 600);
    Beep(700, 200);
    }
    
    
    void h()
    {
    Beep(700, 200);
    Beep(700, 200);
    Beep(700, 200);
    Beep(700, 200);
    }
    
    
    void i()
    {
    Beep(700, 200);
    Beep(700, 200);
    }
    
    
    void j()
    {
    Beep(700, 200);
    Beep(700, 600);
    Beep(700, 600);
    Beep(700, 600);
    }
    
    
    void k()
    {
    Beep(700, 600);
    Beep(700, 200);
    Beep(700, 600);
    }
    
    
    void l()
    {
    Beep(700, 200);
    Beep(700, 600);
    Beep(700, 200);
    Beep(700, 200);
    }
    
    
    
    
    void m()
    {
    Beep(700, 600);
    Beep(700, 600);
    }
    
    
    void n()
    {
    Beep(700, 600);
    Beep(700, 200);
    }
    
    
    void o()
    {
    Beep(700, 600);
    Beep(700, 600);
    Beep(700, 600);
    }
    
    
    void p()
    {
    Beep(700, 200);
    Beep(700, 600);
    Beep(700, 600);
    Beep(700, 200);
    }
    
    
    void q()
    {
    Beep(700, 600);
    Beep(700, 600);
    Beep(700, 200);
    Beep(700, 600);
    }
    
    
    void r()
    {
    Beep(700, 200);
    Beep(700, 600);
    Beep(700, 200);
    }
    
    
    void s()
    {
    Beep(700, 200);
    Beep(700, 200);
    Beep(700, 200);
    }
    
    
    void t()
    {
    Beep(700, 600);
    }
    
    
    void u()
    {
    Beep(700, 200);
    Beep(700, 200);
    Beep(700, 600);
    }
    
    
    void v()
    {
    Beep(700, 200);
    Beep(700, 200);
    Beep(700, 200);
    Beep(700, 600);
    }
    
    
    void w()
    {
    Beep(700, 200);
    Beep(700, 600);
    Beep(700, 600);
    }
    
    
    void x()
    {
    Beep(700, 600);
    Beep(700, 200);
    Beep(700, 200);
    Beep(700, 600);
    }
    
    
    void y()
    {
    Beep(700, 600);
    Beep(700, 200);
    Beep(700, 600);
    Beep(700, 600);
    }
    
    
    void z()
    {
    Beep(700, 600);
    Beep(700, 600);
    Beep(700, 200);
    Beep(700, 200);
    }
    I'm trying to implement Morse code program. However, I cannot find any codes which make a time gap between the letters. Does anyone know the time gap code?

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,616
    You need a pause. You can easily simulate it by doing Beep with a very low frequency( so it wouldn't be heard ), or since you're already using Windows functions use the WinAPI Sleep function.
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,200
    This is not a C++ problem at all. Suggest moderators move this thread to the Windows programming forum.

    There is a function named Sleep() in the WIN32 API (the same API that has the Beep() function) that suspends execution of the current thread for a specified interval.
    Right 98% of the time, and don't care about the other 3%.

  4. #4
    Registered User
    Join Date
    Feb 2013
    Posts
    40
    Thx guys!! Btw I thought this was C++ problem....

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,428
    Quote Originally Posted by tosihiro2007 View Post
    Btw I thought this was C++ problem....
    Sure, the language is C++. But you are using the Win32 API, which isn't part of the C++ standard.
    The C++ forum is for questions about the actual language and not 3rd party APIs.
    Generally, any C++ code that uses external libraries may also be posted here, but in case of the Win32 API and/or Windows programming, the Windows board is a better forum because it's about the actual Win32 API and how to use it properly.
    Make sense? Yes? No?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beep
    By misterowakka in forum C++ Programming
    Replies: 3
    Last Post: 01-29-2008, 04:19 PM
  2. linux beep function
    By Calef13 in forum C++ Programming
    Replies: 7
    Last Post: 07-14-2007, 01:39 AM
  3. Any function like beep(.)?
    By asmileguo in forum C++ Programming
    Replies: 2
    Last Post: 09-14-2006, 02:16 PM
  4. C Beep Function Simple Question
    By Matt3000 in forum C Programming
    Replies: 5
    Last Post: 07-19-2006, 06:43 PM
  5. off VIM beep..
    By hermit in forum Tech Board
    Replies: 3
    Last Post: 06-17-2003, 10:39 PM

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