看板 C_and_CPP 關於我們 聯絡資訊
※ 引述《kentlle (kentlle)》之銘言: 後來發現,原來 VC 中真的也有 dos.h 然而 VC 裡的 dos.h 並不提供 TC 的 sound() 與 nosound() 函數 打開後看後似乎只提供與硬碟空間、檔案相關之函數 即使網路上也提供了 TC 版的 dos.h, 下載更名 dos2.h ,但在 VC 中就 complier 不過去了, complier 除了警告該語法現在已不支援外, 最大問題乃在於:TC 版的 dos.h 其 class 竟不是識別字 偏偏 struct 裡頭還包了一個資料成員名叫 class 的.. 回歸問題 windows.h 裡的指令幾乎可以全部取代 TC 版的 dos.h 其中 BOOL Beep( DWORD dwFreq, DWORD dwDuration ); 便可取代 sound(), (使用後應該也不用 nosound 吧..) 修改執行如下, (sounds like "二隻老虎") : 程式碼如下: : #include <stdio.h> // #include <dos.h> #include <windows.h> : void main (void) : { // sleep(3); Sleep(3); : unsigned f[]={523,587,659,523,523,587,659,523, : 659,698,784,784,659,698,784,784, : 784,880,784,698,659,523, : 784,880,784,698,659,523, : 523,392,523,523,523,392,523}; : unsigned d[]={500,500,500,500,500,500,500,500, : 500,500,500,500,500,500,500,500, : 250,250,250,250,500,500, : 250,250,250,250,500,500, : 500,500,1000,500,500,1000}; : int i; : for (i=0;i<34;i++) : { // sound(f[i]); // delay(d[i]); Beep(fi[i], d[i]); } // nosoud(); : } 這樣應該可以達到你的需求了.. 如果日後還有其它類似問題, 你還是直接先砍 windows.h , 我想這樣比較快.. -- 我期待 我等待 肩狹骨上的翅膀早些長出來 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 180.177.76.142