我是一名新手程序员,我正在尝试使用 Beep 函数用 C++ 制作钢琴。问题是,我在按键时听不到声音。这是我的代码:
#include <cstdlib>
#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <conio.h>
using namespace std;
int main(){
bool ciclo = true;
char tecla = _getch();
while (ciclo);
if (tecla == 'd'){
Beep(261, 100);
}
if (tecla == 'f'){
Beep(293, 100);
}
if (tecla == 'g'){
Beep(329, 100);
}
if (tecla == 'h'){
Beep(349, 100);
}
if (tecla == 'j'){
Beep(392, 100);
}
if (tecla == 'k'){
Beep(440, 100);
}
if (tecla == 'l'){
Beep(493, 100);
}
if (tecla == 'k'){
Beep(523, 100);
}
if (tecla == 'q'){
ciclo = false;
};
if (tecla == 'r'){
Beep(277, 100);
}
if (tecla == 't'){
Beep(312, 100);
}
if (tecla == 'u'){
Beep(370, 100);
}
if (tecla == 'i'){
Beep(415, 100);
}
if (tecla == 'o'){
Beep(466, 100);
}
}
我真的找不到任何问题,所以任何帮助将不胜感激。我正在 Visual Studio 2013 上编译。