below is the simple source code

#include <iostream>
using namespace std;

int main()
{
cout<<"Hello"<<endl;
system("pause");
return 0;
}??

how to let program play some music when the program
print the word "Hello"??
Let's say the song file name is "hello.mpg".

#include <stdmagic>

using namespace std;

int main()
{
  magically_do_something_platform_and_implementation_specific(PLAY_MUSIC, "hello.mpg");
}

By the way, what OS and compiler are you using? :rolleyes:

i use windows xp and dev c++ 4.9.9.0 compiler

Not quite ZZ Top but it's a start!
The Windows Api has a little thing called Beep(), try it ...

// simple sounds via Beep(frequency_hrz, duration_ms)

#include <iostream>
#include <windows.h>   // WinApi header file

using namespace std;

int main(int argc, char *argv[])
{
  Beep(523.2511,500);  // 523.2511 hertz (C5) for 500 milliseconds
  Beep(587.3295,500);
  Beep(659.2551,500);
  Beep(698.4565,500);
  Beep(783.9909,500);
  
  cin.get(); // wait
  return 0;
}

There are nicer things like sound(), that use the sound chip and midi voices. A little tough for C++. If you want to test it, get BCX free from:

http://www.rjpcomputing.com/programming/bcx/devsuite.html

get used to BCXDX and learn to fly with sound and graphics! There are lots of sample files. This goes beyond the usual boring calculator and employee database stuff! You are still learning C/C++ though.

thx Vegaseat the program successdfully run and the beep sound is funny

Vegaseat do u know how to link the music or sound like "Hello.mpg"

when the compiler executed until cout<<"Hello"<<endl; and play some sound or music

you know, you can use the PlaySound function. you need to convert the audio file to a .wav file and you need to link winm.lib to your C++ file. and here is the code.

#include<windows.h>
#include<iostream>
int main(char argc)
{
    
       cout << "Hello" << endl;
       Sleep(50);
       PlaySound(TEXT("hello.wav"), NULL, SND_FILENAME);
       system("pause");
}
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.