简体   繁体   中英

How do I Display Something in the Exact Middle of the Display Screen?

I'm looking to add something exciting to my final project this semester. I'm trying to create a text-based combat game and I'm using a round counter for each attack. I want the round counter to display in the middle both vertically and horizontally of a blank screen between rounds. I know how to clear the screen, but how do I display it in the center? I thought of using

cout << "                  Round 1                    ";

but in order for that to display in the middle, the only thing I know how to do is to add like, 20 lines of

cout << endl;

Please help me.

If you'd like to keep your game in the console window, ncurses allows you to set where you'd like to print.

You are also given the option of some GUI stuff like menus, message boxes, etc.

Others have posted similar solutions to this here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM