There is another way to make a sound, quite simple, you load a wave file and play it:

// play a wave file sound using the winmm library
// For DevCpp add the library libwinmm.a to linker via 
// Project/Project Options/Parameters/Add Library
// remember this is a console program!

#include <iostream>
#include <windows.h>   // for PlaySound()

#define SND_FILENAME 0x20000
#define SND_LOOP 8
#define SND_ASYNC 1

using namespace std;

int main()
{
  // play sound as loop (remove SND_LOOP for one time play)
  // file boing.wav has be in the working directory
  PlaySound("boing.wav",NULL,SND_FILENAME|SND_LOOP|SND_ASYNC); 
  
  cin.get(); // wait
  return 0;
}

Will this work even in C while i use a turbo or borland C compiler. If it does where do i get the winmm library?

It will not work with Turbo C because that compiler can not call any of the ms-windows library functions. As for borland, it depends on which version you are using. If its a 16-bit version like Turbo C, then that compiler will not work either.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.