C++関連

・Sleep(msec)

 #include <Windows.h>

 Sleep(1000);  //1秒

 

・text color

 ヘッダーファイル

#define BLACK        0x00
#define DARK_BLUE   0x01
#define DARK_GREEN    0x02
#define DARK_CYAN   0x03
#define DARK_RED    0x04
#define DARK_VIOLET    0x05
#define DARK_YELLOW 0x06
#define GRAY        0x07
#define LIGHT_GRAY  0x08
#define BLUE        0x09
#define GREEN        0x0a
#define CYAN        0x0b
#define RED            0x0c
#define VIOLET        0x0d
#define YELLOW        0x0e
#define WHITE        0x0f
#define INTENSITY    0x08 // 高輝度マスク
#define RED_MASK    0x04 // 赤色ビット
#define GREEN_MASK    0x02 // 緑色ビット
#define BLUE_MASK   0x01 // 青色ビット 

 

 ソースファイル

 HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);

 SetConsoleTextAttribute(h, YELLOW);

 printf("HALLO!!\n");

 

・gotoxy(int x, int y)

 ヘッダファイル

 void gotoXY2(int x, int y);

 ソースファイル

 gotoXY2(1, 1);

 

void gotoXY2(int x, int y) {
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}