gpt4 book ai didi

c++ - ReadConsoleOutputCharacter 在请求超过 0xCFE1 个字符时给出 ERROR_NOT_ENOUGH_MEMORY,有没有办法解决这个问题?

转载 作者:太空宇宙 更新时间:2023-11-04 16:14:44 33 4
gpt4 key购买 nike

代码:

#include <windows.h>
#include <stdio.h>
int main() {
system("mode 128");
int range = 0xCFE2;
char* buf = new char[range+1];
DWORD dwChars;
if (!ReadConsoleOutputCharacter(
GetStdHandle(STD_OUTPUT_HANDLE),
buf, // Buffer where store symbols
range, // Read len chars
{0,0}, // Read from row=8, column=6
&dwChars // How many symbols stored
)) {
printf("GetLastError: %lu\n", GetLastError());
}
system("pause");
return 0;
}

最佳答案

控制台屏幕缓冲区不能大于 64K。缓冲区中的每个字符需要 2 个字节,一个用于字符代码,另一个用于颜色属性。因此,尝试使用 ReadConsoleOutputCharacter() 读取超过 32K 的字符毫无意义。

你没有真正的问题。

关于c++ - ReadConsoleOutputCharacter 在请求超过 0xCFE1 个字符时给出 ERROR_NOT_ENOUGH_MEMORY,有没有办法解决这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23943193/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com