【发布时间】:2021-08-29 09:47:16
【问题描述】:
我认为这个问题以前没有被问过,但这里是:
当我在 VS2019 中运行我的程序时,输出窗口会根据错误正确执行。
但是这次我是在创建一个程序,这取决于全屏控制台输出窗口的列和行长度。
但我注意到列数多于行数,因为输出窗口附带了额外的空白。
我已经修改了我的代码作为示例:
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <Windows.h>
#include <string>
using namespace std;
int main() {
SetConsoleDisplayMode(GetStdHandle(STD_OUTPUT_HANDLE), CONSOLE_FULLSCREEN_MODE, 0);
CONSOLE_SCREEN_BUFFER_INFO csbi;
int WindowColumns, WindowRows, DisplayBuffer, DisplayColumns, DisplayRows;
string DisplayMap;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
WindowColumns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
WindowRows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
return 0;
}
这是输出:
237,67
上面的输出首先显示列,然后显示行。我确信这一点。列数多于行数,应该是相反的,考虑到我的屏幕分辨率是1920x1080
显示输出中生成的空白数量的屏幕截图:
I dont have enough reputation to embed the image, so here's a link
我的问题是:我如何摆脱这个额外的空白,它应该只匹配行和列的长度。 你能帮我解决这个问题吗?
提前致谢。
【问题讨论】:
-
您发布的图像只是一个滚动条的PNG图像,只有21像素宽。我没有看到任何控制台窗口。
标签: c++ visual-studio window output whitespace