I am a novice programmer and I am trying to make a piano with C++, using the Beep function. the problem is, I can't hear the sounds when I press the keys. Here's my code:
#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);
}
}
I seriously can't find anything wrong in it, so any help would be appreciated. I'm compiling on Visual Studio 2013.
Maybe your computer has not PC speaker. Look at the docs: https://msdn.microsoft.com/en-us/library/windows/desktop/ms679277(v=vs.85).aspx