如何在turbo C中播放音频文件

编程入门 行业动态 更新时间:2024-10-05 11:18:42
本文介绍了如何在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特定行:

  • stdafx.h 是一个使用的文件(和创建)由VS支持预编译的头文件并包含所需的Windows头文件
  • #pragma comment(lib,...)是VS特定的预处理器指令,用于链接指定的库
  • 使用任何其他C / C ++编译代码编译器,您必须将其配置为使用Windows SDK的包含和库文件路径,删除上面提到的两行,可能添加包括 Windows.h ,并链接到 winmm。 lib 。 我强烈建议你不要再使用Turbo C / C ++了t写一个DOS应用程序。但那些不能使用Windows库。

    从这里: C ++如何使用Turbo C ++播放声音 [ ^ ] #include < 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:

  • stdafx.h is a file used (and created) by VS to support pre compiled headers and include the required Windows header files
  • #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中播放音频文件

    本文发布于:2023-11-28 03:17:27,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1640756.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:音频文件   如何在   turbo

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!