[英]An invalid parameter was passed to a function that considers invalid parameters fatal?
"Unhandled exception at 0x7A3AF2F6 (ucrtbased.dll) in Stream Board.exe: An invalid parameter was passed to a function that considers invalid parameters fatal." “Stream Board.exe 中 0x7A3AF2F6 (ucrtbased.dll) 处的未处理异常:无效参数已传递给认为无效参数致命的 function。”
No idea what ive done wrong ngl...不知道我做错了什么ngl ...
#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;
}
You are going out of bounds of an array:您将超出数组的范围:
bool played=PlaySound(CP_ACP(SongNames[1]), NULL, SND_SYNC);
You should access the first element, not the second, which does not exist from what you showed.您应该访问第一个元素,而不是第二个元素,这在您展示的内容中不存在。
bool played=PlaySound(CP_ACP(SongNames[0]), NULL, SND_SYNC);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.