如何获取控制台中我的进程绑定到行中的字符数? [英] how to get number of characters in line in console that my process is bind to?
本文介绍了如何获取控制台中我的进程绑定到行中的字符数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
重新整理我的问题:控制台的字符宽度。
这在windows中默认设置为80,但用户可以更改它,如何获得
解决方案
您可以使用 GetConsoleScreenBufferInfo
函数。
$ b
CONSOLE_SCREEN_BUFFER_INFO csbi;
if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),& csbi))
{
//错误出现
cerr<<无法确定控制台大小。 < endl;
}
else
{
cout<<控制台是<< csbi.srWindow.Right-csbi.srWindow.Left<<wide。 <<< endl;
}
Rephrasing my question: width of a console in term of characters.
This in windows is set by default to 80 but user can change it, how to get this value ?
解决方案
You can use the GetConsoleScreenBufferInfo
function.
CONSOLE_SCREEN_BUFFER_INFO csbi;
if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
{
// an error occourred
cerr<<"Cannot determine console size."<<endl;
}
else
{
cout<<"The console is "<<csbi.srWindow.Right-csbi.srWindow.Left<<" wide."<<endl;
}
这篇关于如何获取控制台中我的进程绑定到行中的字符数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文