Well I've gone back to basics and learning开发者_如何学Python C++ from scratch as the last time I coded any it was years ago. Currently working under Windows cli until getting the Linux box on again. I'm using
cout << "\a" << flush;
to make my system create a noise but on looping, there is always a delay - not so good for making longer pulses. I know under C# and Basic there was a way to use the computers buzzer but do not know the c++ way. Any help please?
I don't think there's a standard way to control a computer's internal speaker. How you would do so depends on which operating system you're working under. Under the Windows API, there's a Beep function, and under Linux, you can use ioctl. Your programming language has little to do with it; this is a library question.
Windows: http://msdn.microsoft.com/en-us/library/ms679277(v=vs.85).aspx
For non-Windows, it's a little more complicated, but take a look at the source of the "beep" program for help, especially the play_beep() function and the beep_parms_t structure: http://johnath.com/beep/beep.c
精彩评论