CFanatic

Go Back   CFanatic > Programming > C Programming

Join CFanatic Forum Now

how to make computer beep topic posted under C Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 12-31-2006, 01:09 AM
Junior Member
 
Join Date: Dec 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
jan1024188 is on a distinguished road
| More
how to make computer beep

I have a problem....I wrote program which makes computer beep, but there is no beep when executing a program. I included windows.h header, defined speed and wrote following line

Code:
Beep(2750, speed);
Why there is no beep?
Reply With Quote
  #2  
Old 12-31-2006, 01:14 AM
shabbir's Avatar
Administrator
 
Join Date: Sep 2006
Posts: 1,159
Thanks: 48
Thanked 62 Times in 43 Posts
shabbir has a spectacular aura aboutshabbir has a spectacular aura about
| More
Re: how to make computer beep

Moved thread from Advance C to Begining C.
Reply With Quote
  #3  
Old 07-27-2007, 09:58 AM
Junior Member
 
Join Date: Jul 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
LaRoza is on a distinguished road
| More
Re: how to make computer beep

I dont know exactly what you want to do, but if you want a beep, use '\a'.

Here is an example so you can see it:
Code:
#include <stdio.h>
int main(void)
{
    printf("\a");
    return 0;
}
Reply With Quote
  #4  
Old 07-27-2007, 11:08 AM
Junior Member
 
Join Date: Jun 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
tiger12506 is on a distinguished road
| More
Re: how to make computer beep

\a does not work in Windows.
And Beep does not work in non-Windows environments

Perhaps your frequency of 2750 is higher than you expect, and you are missing it? Try 440. You *will* hear that.

And what is your value for speed? Make sure that it is at least 500, or you will miss the beep!

A better name would be 'duration'. (in milliseconds)

Cheers.
Reply With Quote
  #5  
Old 07-30-2007, 08:22 AM
Junior Member
 
Join Date: Jul 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
LaRoza is on a distinguished road
| More
Re: how to make computer beep

\a works, I just compiled and ran the exact code I posted and it worked fine in Windows XP Pro.
Reply With Quote
  #6  
Old 09-12-2007, 09:46 AM
Junior Member
 
Join Date: Aug 2007
Location: East Coast USA
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
HowardL is on a distinguished road
| More
Re: how to make computer beep

Interesting... I found another in stdlib.h
I get the same darn ding.wav for all of these though. No change at all...
I'm in win98 on the old laptop using the mingw gnu C compiler.
Code:
#include <stdio.h>            /*  beep1.c  */
#include <windows.h>
#include <stdlib.h>

int main(void)
{
    int i, j, speed = 2000;

    printf("1 \a \n");      /* works with just stdio.h */
     Sleep(1000);            /* need windows.h */
                      /* must wait before dings or I won't get ding
                         I guess 'cause it's working so hard to make it: ) */

    printf("2  \n");
    putchar(0x07);          /* works with just stdio.h */
    Sleep(1000);

    printf("3  \n");
    Beep(2750, speed);      /* need windows.h */
    Sleep(1000); 
    
    printf("4  \n");
    _beep(2750, speed);     /* need stdlib.h */
    _sleep(1000);           /* need stdlib.h */


    /* I get the same Beep for all of these */

    for(i = 400; i <= 2000; i += 400 ) {
      for(j = 400; j <= 2000; j += 400) {
        printf("Beep(%d, %d)  \n", i, j);
        Beep(i, j);
        /* Beep(200, speed); */
        Sleep(1000);
      }
    }
    return 0;
}
/*
Here's where they come from in my mingw - includes directory:
-----
winbase.h
BOOL WINAPI Beep(DWORD,DWORD);
-----
stdlib.h
/ *
 * NOTE: Officially the three following functions are obsolete. The Win32 API
 *       functions SetErrorMode, Beep and Sleep are their replacements.
 * /
_CRTIMP void __cdecl	_beep (unsigned int, unsigned int);
_CRTIMP void __cdecl	_seterrormode (int);
_CRTIMP void __cdecl	_sleep (unsigned long);
*/
funny...
Howard;

Last edited by HowardL; 09-12-2007 at 09:56 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make computer shutdown in C jan1024188 C Programming 4 11-23-2007 10:44 AM
Computer problem leoman730 C Programming 1 07-27-2007 10:28 AM
how to make window transparent vidhya Win32 Programming 10 06-08-2007 04:31 PM
How a six-year-old beat the House of Commons computer system NewsBot News 0 03-29-2007 12:58 AM
Types of computer viruses JokesBot The Lounge 0 10-29-2006 02:57 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 04:05 AM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board