| |

VerySource

 Forgot password?
 Register
Search
View: 891|Reply: 2

Can anyone help me to see what is wrong with this code?

[Copy link]

2

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-3-19 22:00:01
| Show all posts |Read mode
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;
      }
    }
  }
}
Reply

Use magic Report

2

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-7-2 19:15:01
| Show all posts
Is the problem with that judgment sentence?
if(store[j-1]==three[m][0]&&store[j]==three[m][1]&&store[j+1]==three[m][2])
Reply

Use magic Report

2

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-7-3 15:15:01
| Show all posts
The problem has been solved
It was modified once when it was defined before, but it was not changed, and I forgot to change it later --b
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list