Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SFML访问冲突 我在C++中编写了一个俄罗斯方块游戏,在DouthBooRad()函数中,我得到一个错误: 在Tetris_C++.exe中的0x0F52DA36(sfml-graphics-d-2.dll)处引发异常:0xC0000005:访问冲突写入位置0x013EDA88_C++_Exception_Sfml_Access Violation - Fatal编程技术网

SFML访问冲突 我在C++中编写了一个俄罗斯方块游戏,在DouthBooRad()函数中,我得到一个错误: 在Tetris_C++.exe中的0x0F52DA36(sfml-graphics-d-2.dll)处引发异常:0xC0000005:访问冲突写入位置0x013EDA88

SFML访问冲突 我在C++中编写了一个俄罗斯方块游戏,在DouthBooRad()函数中,我得到一个错误: 在Tetris_C++.exe中的0x0F52DA36(sfml-graphics-d-2.dll)处引发异常:0xC0000005:访问冲突写入位置0x013EDA88,c++,exception,sfml,access-violation,C++,Exception,Sfml,Access Violation,如果存在此异常的处理程序,则程序可以安全地继续 代码如下: void DrawBoard() { for (int i = 0; i < boardWidth; i++) { for (int j = 0; j < boardHeight; i++) { switch (board[i][j]) {//What's wrong with this? case 'b': squares[i][j].setFill

如果存在此异常的处理程序,则程序可以安全地继续

代码如下:

void DrawBoard() {

for (int i = 0; i < boardWidth; i++)
{
    for (int j = 0; j < boardHeight; i++)
    {
        switch (board[i][j]) {//What's wrong with this?
        case 'b':
            squares[i][j].setFillColor(sf::Color::Blue);
            break;
        case 'c':
            squares[i][j].setFillColor(sf::Color::Cyan);
            break;
        case 'y':
            squares[i][j].setFillColor(sf::Color::Yellow);
            break;
        case 'o':
            squares[i][j].setFillColor(sf::Color(255, 165, 0));//Orange
            break;
        case 'p':
            squares[i][j].setFillColor(sf::Color(150, 50, 250));//Purple
            break;
        default:
            break;
        }
    }
}

for (int x = 0; x < boardWidth; x++) {
    for (int y = 0; y < boardHeight; y++) {
        window.draw(squares[x][y]);
    }
}
void DrawBoard(){
对于(int i=0;i

}

该错误仅表示您的程序试图访问其分配地址空间之外的内存。
但是如果没有看到一个错误,就不可能知道你的错误在哪里。猜测可能是您的一个变量已超出范围,或者您正试图访问
方格
数组的边界之外的变量,但同样,这只是基于不完整信息的猜测。

欢迎使用堆栈溢出。请花点时间阅读并参考您可以在此处询问的内容和方式。解决此类问题的正确工具是调试器。在询问堆栈溢出之前,应该逐行检查代码。如需更多帮助,请阅读。至少,您应该[编辑]您的问题,以包括一个重现您的问题的示例,以及您在调试器中所做的观察。在不知道什么是
board
squares
的情况下,没有人能够帮助您。谢谢,这是一个打字错误,现在一切正常。
for (int j = 0; j < boardHeight; i++)
for (int j = 0; j < boardHeight; j++)