|
This code is good when i> = 2, but it doesn't work when i> = 3, can't play WAV file, the array is not out of bounds.
if (i> = 2)
{
for (int j = i-1; j <= i; j ++)
{
for (int m = 0; m <28; m ++)
{
if (store [j-1] == two [m] [0]&&store [j] == two [m] [1])
{
for (int k = j; k <j + 2; k ++)
{
PlaySound ((LPCTSTR) m_WaveId [store [k-1]], AfxGetInstanceHandle (), SND_RESOURCE | SND_NOSTOP);
}
return;
}
}
}
}
The above is good code to play WAV files
The following is the code in question, compiled and passed without any problems, the program can run, but the WAV file cannot be played
if (i> = 3)
{
for (int j = i-2; j <= i; j ++)
{
for (int m = 0; m <7; m ++)
{
if (store [j-1] == three [m] [0]&&store [j] == three [m] [1]&&store [j + 1] == three [m] [2])
{
for (int k = j; k <j + 3; k ++)
{
PlaySound ((LPCTSTR) m_WaveId [store [k-1]], AfxGetInstanceHandle (), SND_RESOURCE | SND_NOSTOP);
}
return;
}
}
}
} |
|