搜尋此網誌

[C/C++][印出不同字體顏色與背景]

/*
* Author: MH
* Since 2014/11/11
* Toolkit: Code::Block 13.12
*/

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

int main()
{
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    int colorIndex;

    for(colorIndex=0; colorIndex<255; colorIndex++)
    {
        SetConsoleTextAttribute(hConsole, colorIndex);
        printf("%3d %s\n", colorIndex, "Hello World!");
    }

    SetConsoleTextAttribute(hConsole, 15);
    system("PAUSE");
    return 0;
}

沒有留言:

張貼留言