举报

为什么在调用easyx后,程序会自动崩溃

0

操作系统 windows10 编译环境 visual studio 2022 EASYX版本 2023大暑版

在清屏之后,程序有时候会突然崩溃,有的时候就可以正常运行。

返回值是 -1073741819,调试调用堆栈发现是ntdll.RtlpWaitOnCriticalSection()函数出了问题,但是没有指明具体哪一个变量有问题

#include <graphics.h>
#include <conio.h>
#include <iostream>

using namespace std;

void show()
{
    const int width = 640;
    const int length = 320;
    initgraph(width, length, EX_SHOWCONSOLE | EX_NOCLOSE);                                         // 设置图形窗口大小
    _getch();
    closegraph();
}

int main() {
    // 初始化图形界面
    printf("hello");                                                                               // 控制台窗口显示hello
    show();
    system("cls");                                                                                 // 清屏
    _getch();
    return 0;
}
ava
槿华

2023-11-10

举报
0

可能是 windows 升级了控制台导致的某些兼容问题。

目前办法:用 getmessage(EX_CHAR) 替代 _getch 和 system("cls") 可以解决问题。

ava
慢羊羊

2023-11-10

技术讨论社区