C++ 向认为无效参数致命的函数传递了无效参数?
“Stream Board.exe中0x7A3AF2F6(基于UCRTBASE.dll)处未处理的异常:向认为无效参数为致命参数的函数传递了无效参数。” 不知道我做错了什么nglC++ 向认为无效参数致命的函数传递了无效参数?,c++,C++,“Stream Board.exe中0x7A3AF2F6(基于UCRTBASE.dll)处未处理的异常:向认为无效参数为致命参数的函数传递了无效参数。” 不知道我做错了什么ngl #include <iostream> #include <Windows.h> #include <mmsystem.h> #include <string> #include <fstream> using namespace std; con
#include <iostream>
#include <Windows.h>
#include <mmsystem.h>
#include <string>
#include <fstream>
using namespace std;
const int NumberOfSongs = 1;
string SongNames[NumberOfSongs];
int main()
{
ifstream file("List_Of_Songs.txt");
if (file.is_open())
{
for (int i = 0; i < NumberOfSongs; i++)
{
file >> SongNames[i];
}
}
bool played=PlaySound(CP_ACP(SongNames[1]), NULL, SND_SYNC);
cout << SongNames[1] << endl;
}
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
常数int NumberOfSongs=1;
字符串歌曲名[NumberOfSongs];
int main()
{
ifstream文件(“List_Of_Songs.txt”);
if(file.is_open())
{
for(int i=0;i>歌曲名称[i];
}
}
布尔播放=播放声音(CP_ACP(歌曲名称[1]),空,SND_同步);
cout您正在超出数组的边界:
bool played=PlaySound(CP_ACP(SongNames[1]), NULL, SND_SYNC);
您应该访问第一个元素,而不是第二个元素,它在您显示的内容中不存在
bool played=PlaySound(CP_ACP(SongNames[0]), NULL, SND_SYNC);
考虑<代码>歌曲名称<代码>中的什么元素<代码>歌曲名称[1 ] < /代码>?第一个<代码> < <代码>循环从<代码> 0 > /代码>开始。因此第一首歌曲在索引0,而不是1。