多线cout

时间:2015-07-06 09:14:10

标签: c++

有没有办法只用一个命令就可以完成这段代码,或者更好地理解,这是一种多行cout?我问,因为我试图使用这个菜单,但菜单加载时看起来很草率。

#include <windows.h>
#include <iostream>

using namespace std;

void setCursorPos(int, int);
//setCursorPos - Sets position of console cursor
//@param int - the new x position of the cursor
//@param int - the new y position of the cursor



SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 0x70);
int x, y;
x = 0;
y = 0;
while(y <= 24)
{
    while(x <= 79)
    {
        setCursorPos(x, y);
        cout << " ";
        x++;
    }
    x = 0;
    y++;
}

//Function
void setCursorPos(int x, int y)
{
    COORD Coord;

    Coord.X = x;
    Coord.Y = y;

    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Coord);
}

0 个答案:

没有答案