简体   繁体   English

将无效参数传递给认为无效参数致命的 function?

[英]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.

相关问题 C++ 一个无效参数被传递给一个认为无效参数致命的 function - C++ An invalid parameter was passed to a function that considers invalid parameters fatal 未处理的异常:一个无效的参数被传递给 function,它认为无效参数在 UWP 应用程序中是致命的 - Unhandled exception: An invalid parameter was passed to a function that considers invalid parameters fatal in UWP application C++ 未处理异常:无效参数被传递给认为无效参数致命的函数 - C++ Unhandled exception: An invalid parameter was passed to a function that considers invalid parameters fatal 通过QTest将无效的参数传递给C运行时函数 - Invalid parameter passed to C runtime function with QTest C ++:无效的参数传递给C运行时函数 - C++: Invalid parameter passed to C runtime function 如何调试“传递给 C 运行时函数的参数无效”? - how to debug “Invalid parameter passed to C runtime function”? 组合模板参数以形成函数签名时,void参数无效 - Invalid void parameter when combining template parameters to form a function signature 为什么这个程序告诉我传递了无效参数? - Why is this program telling me invalid parameter was passed? 必须在将QWidget和Invalid参数传递给C运行时函数之前构造QApplication - Must construct a QApplication before a QWidget & Invalid parameter passed to C runtime function 函数传递参数中遇到无效的八进制格式 - Invalid octal format encountered in function passing parameter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM