Please help me out in making the program to play the music file in c.
i did tried to search a lot on web but couldnt get any clue about it.

Dani AI

Generated

Given reported Windows XP and Turbo C, the core issue is the compiler/OS mismatch. Turbo C is a 16-bit DOS-era compiler and cannot call modern Win32 APIs. As suggested, use a Win32-capable compiler (for example MinGW GCC or Microsoft Visual C++) so the program can call Windows multimedia APIs.

A simple, immediate method on Windows XP for playing WAV files is the WinMM API PlaySound. Example C program:

#include <windows.h>
#include <mmsystem.h>

int main(void)
{
    PlaySound("C:\\path\\to\\sound.wav", NULL, SND_FILENAME | SND_SYNC);
    return 0;
}

Compile/link with the WinMM library (MinGW: gcc play.c -o play.exe -lwinmm; MSVC: supply winmm.lib or use #pragma comment(lib, "winmm.lib")). Use SND_ASYNC instead of SND_SYNC for nonblocking playback. PlaySound is for WAV files; MP3 support is not guaranteed.

For MP3 or advanced features, use MCI (mciSendString) or higher-level libraries (DirectSound/DirectShow or third-party engines like BASS, FMOD, libVLC). This complements 's DirectSound suggestion: DirectSound and media libraries provide more control (streaming, formats, mixing), but require a Win32 build and more code.

Troubleshooting tips: always test with an absolute file path; verify the file format is supported by the chosen API; ensure the program is built as a 32-bit Win32 executable and linked against winmm; check for permissions and that the file is not in use. If the environment must remain Turbo C, playing sound via modern Windows APIs is not feasible; moving to a modern compiler is the practical first step.

Recommended Answers

All 4 Replies

Agreed. Just a wild guess, if you're using Windows, check out DirectSound (msdn, google search will serve you well). But this of course would come after substantial knowledge and experience with the language.

i ahve windowsw xp as the os and turbo C compiler

Neither do we, until you tell us which OS and Compiler you're using.

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.