Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sound(x)

Status
Not open for further replies.

curlyj

Programmer
Apr 8, 2001
10
GB
Hi!
Im new to C++ and have been reading through C For Dummies Volume 1

I am using Borland C++ 5.5.1
the book states that although it is written for C the book works for C++ as well.

in the book there is the following example that is to be typed in, yet it will not work. Could anyone help?
Thanx!

The code...............


#include<stdio.h>
#include<conio.h>
#include <dos.h>

void dropbomb(void);

void main()
{
printf(&quot;Press any key to drop bomb:&quot;);
getch();
dropbomb();
printf(&quot;\nYikes!\n&quot;);
}

void dropbomb()
{
int x;

for (x=880;x>440;x-=10)
{
sound(x);
delay(100);
}
nosound();
}
QBasic is fun! Go see what I've done!
 
sound() is neither a C or C++ function or keyword.
Your example probably is older DOS code written for a compiler that supported this compiler specific function call. You are most likely compiling Win32 console programs with Borland C++ 5.5.1 which are only simular to DOS programs in looks. You can use,
Beep(
DWORD dwFreq, // sound frequency, in hertz
DWORD dwDuration // sound duration, in milliseconds
);
under Windows NT. Under Win95, the parameters are ignored and windows plays the default sound.


Also, use int main() instead of void main() and use return 0; at the end of main.


Kim_Christensen@telus.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top