I'm trying to create a program that plays different sounds when you press different keys. I was planning to take the char key , add the string ".wav" and input that new string called "sound" into the line:
PlaySound(TEXT(sound), NULL, SND_FILENAME | SND_ASYNC);
The code does not compile and gives the error "identifier 'Lsound' is undefined" I've tried replacing "TEXT" with "string" but it gives the error message "no suitable conversion function from 'std::string' to 'LPCWSRT' exists".
Any help with a solution would be greatly appreciated.
#include <iostream>
#include <Windows.h>
using namespace std;
int main() {
char i;
while (true) {
for (i = 8; i <= 255; i++) {
if (GetAsyncKeyState(i) == -32767) {
string sound = i + ".wav";
PlaySound(TEXT(sound), NULL, SND_FILENAME | SND_ASYNC);
}
}
}
return 0;
}