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?
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; }
\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.
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;