如何在turbo C中播放音频文件 [英] How to play audio files in turbo C

查看:136
本文介绍了如何在turbo C中播放音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好......!

我想写一个 C / C ++ 程序来播放音频文件。我成功在 visual studio 中编写了这段代码,但是当我尝试 turbo c 中的代码时,就会出现错误。



我尝试过:



 #includestdafx.h
#includestrsafe.h
#includeMMSystem.h
#pragma comment(lib,winmm.lib)

void main(){
PlaySound(TEXT(File path.wav),NULL,SND_FILENAME | SND_LOOP);
}





这是我在 visual studio 中尝试过的代码。现在想在turbo中播放音频。请帮帮我。

谢谢!

解决方案

Turbo C / C ++是一个来自DOS的古老编译器16位Windows时间(请参阅 Turbo C ++ - Wikipedia [ ^ ])。



虽然它可以安装在最近的Windows版本上,这并不意味着您可以创建在最近的Windows版本上运行的可执行文件。它创建了自Windows 8以来不再支持的16位可执行文件(您需要使用Embarcadero BCC32C / BCC32X C ++编译器来创建可由最近的Windows版本运行的可执行文件。)



您的Visual Studio代码不能与Turbo C ++一起使用,因为它包含两个不受Turbo C支持的VS特定行:

  1. stdafx.h 是一个使用的文件(和创建)由VS支持预编译的头文件并包含所需的Windows头文件

  2. #pragma comment(lib,...)是VS特定的预处理器指令,用于链接指定的库



使用任何其他C / C ++编译代码编译器,您必须将其配置为使用Windows SDK的包含和库文件路径,删除上面提到的两行,可能添加包括 Windows.h ,并链接到 winmm。 lib



我强烈建议你不要再使用Turbo C / C ++了t写一个DOS应用程序。但那些不能使用Windows库。


从这里: C ++如何使用Turbo C ++播放声音 [ ^ ]



< pre lang =c ++> #include < < span class =code-leadattribute> mmsystem.h >

BOOL sndPlaySound(
LPCSTR lpszSound,
UINT fuSound
);





你还必须链接到winmm.lib哪个可以添加



  #pragma comment(lib,winmm.lib)  





到您的源文件


Hello...!
I want to write a C/C++ program to play audio file. I'm successful to write this code in visual studio but when i tried the code in turbo c then there are errors.

What I have tried:

#include "stdafx.h"
#include "strsafe.h"
#include "MMSystem.h"
#pragma comment(lib, "winmm.lib")

void main() {
     PlaySound(TEXT("File path.wav"), NULL, SND_FILENAME | SND_LOOP);
}



This is the code i tried in visual studio. Now to wanna to play audio in turbo. Please help me.
Thanks!

解决方案

Turbo C/C++ is an ancient compiler from the DOS and 16-bit Windows times (see Turbo C++ - Wikipedia[^]).

While it can be installed on recent Windows versions that does not mean that you can create executables running on recent Windows versions. It creates 16-bit executables which are not supported anymore since Windows 8 (you would need the Embarcadero BCC32C/BCC32X C++ compiler to create executables that can be run by recent Windows versions).

Your code for Visual Studio does not work with Turbo C++ because it contains two VS specific lines not supported by Turbo C:

  1. stdafx.h is a file used (and created) by VS to support pre compiled headers and include the required Windows header files
  2. #pragma comment(lib, ...) is as VS specific preprocessor directive to link with the specified library


To compile your code with any other C/C++ compiler, you would have to configure it to use the include and library file paths of the Windows SDK, remove the two lines mentioned above, probably add including Windows.h, and link with winmm.lib.

I strongly suggest to not use Turbo C/C++ anymore besides you want to write a DOS application. But those can't use Windows libraries.


From here:C++ How to play sound using Turbo C++[^]

#include <mmsystem.h>

BOOL sndPlaySound(
  LPCSTR lpszSound,  
  UINT fuSound      
);



youll also have to link to winmm.lib which can be done by adding

#pragma comment(lib,"winmm.lib")



to your source file


这篇关于如何在turbo C中播放音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆