如何将输出与屏幕中心对齐 - C ++? [英] How to align output to center of screen - C++?

查看:190
本文介绍了如何将输出与屏幕中心对齐 - C ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个C ++控制台应用程序。我想执行和打印所有的东西在应用程序窗口中心(水平+垂直)如下所示。

   - ------------------------------- 
| |
| |
|用户:xyz |
|通过:**** |
| |
| |
--------------------------------

我想像上面那样运行我的整个程序。有没有办法做到这一点?
任何帮助或建议,将不胜感激。

解决方案

如果你想保持你的应用程序在控制台,但要做一些布局,我建议使用 ncurses ,因为它可以让你更多的控制在哪里打印,还可以创建菜单,消息框和其他类似图形界面的东西。


I am working on a C++ console app. I want to execute and print all the stuffs at the center of app window screen ( horizontally + vertically) as shown below.

 --------------------------------
|                               |
|                               |
|         User : xyz            |
|         Pass : ****           |
|                               |
|                               |
 --------------------------------

I want to run my whole program as how above. Is there any way to do so? Any help or suggestion would be appreciated.

解决方案

If you want to keep your application in a console, but want to do some layouts I'd recommend using ncurses as it gives you more control on where you print, and also gives you a possibility to create menus, message boxes and other GUI-like stuff.

这篇关于如何将输出与屏幕中心对齐 - C ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆